Home | History | Annotate | Line # | Download | only in include
      1  1.15   maxv /*	$NetBSD: sysarch.h,v 1.15 2020/06/19 16:20:22 maxv 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.10   maxv #define X86_IOPL		2
     38  1.10   maxv #define X86_GET_IOPERM		3
     39  1.10   maxv #define X86_SET_IOPERM		4
     40  1.10   maxv #define X86_OLD_VM86		5
     41   1.1     ad #define X86_GET_MTRR		11
     42   1.1     ad #define X86_SET_MTRR		12
     43  1.10   maxv #define X86_VM86		13
     44  1.10   maxv #define X86_GET_GSBASE		14
     45  1.10   maxv #define X86_GET_FSBASE		15
     46  1.10   maxv #define X86_SET_GSBASE		16
     47  1.10   maxv #define X86_SET_FSBASE		17
     48   1.2     ad 
     49   1.2     ad #ifdef _KERNEL
     50  1.10   maxv #define _X86_SYSARCH_L(x)	x86_##x
     51  1.10   maxv #define _X86_SYSARCH_U(x)	X86_##x
     52   1.4  ragge #elif defined(__i386__)
     53  1.10   maxv #define _X86_SYSARCH_L(x)	i386_##x
     54  1.10   maxv #define _X86_SYSARCH_U(x)	I386_##x
     55   1.1     ad #define I386_GET_LDT		X86_GET_LDT
     56   1.1     ad #define I386_SET_LDT		X86_SET_LDT
     57  1.10   maxv #define I386_IOPL		X86_IOPL
     58  1.10   maxv #define I386_GET_IOPERM		X86_GET_IOPERM
     59  1.10   maxv #define I386_SET_IOPERM		X86_SET_IOPERM
     60  1.10   maxv #define I386_OLD_VM86		X86_OLD_VM86
     61   1.1     ad #define I386_GET_MTRR		X86_GET_MTRR
     62   1.1     ad #define I386_SET_MTRR		X86_SET_MTRR
     63  1.10   maxv #define I386_VM86		X86_VM86
     64  1.10   maxv #define I386_GET_GSBASE		X86_GET_GSBASE
     65  1.10   maxv #define I386_GET_FSBASE		X86_GET_FSBASE
     66  1.10   maxv #define I386_SET_GSBASE		X86_SET_GSBASE
     67  1.10   maxv #define I386_SET_FSBASE		X86_SET_FSBASE
     68   1.1     ad #else
     69  1.10   maxv #define _X86_SYSARCH_L(x)	x86_64_##x
     70  1.10   maxv #define _X86_SYSARCH_U(x)	X86_64_##x
     71   1.1     ad #define X86_64_GET_LDT		X86_GET_LDT
     72   1.1     ad #define X86_64_SET_LDT		X86_SET_LDT
     73  1.10   maxv #define X86_64_IOPL		X86_IOPL
     74  1.10   maxv #define X86_64_GET_IOPERM	X86_GET_IOPERM
     75  1.10   maxv #define X86_64_SET_IOPERM	X86_SET_IOPERM
     76  1.10   maxv #define X86_64_OLD_VM86		X86_OLD_VM86
     77   1.1     ad #define X86_64_GET_MTRR		X86_GET_MTRR
     78   1.1     ad #define X86_64_SET_MTRR		X86_SET_MTRR
     79  1.10   maxv #define X86_64_VM86		X86_VM86
     80   1.6     ad #define X86_64_GET_GSBASE	X86_GET_GSBASE
     81  1.10   maxv #define X86_64_GET_FSBASE	X86_GET_FSBASE
     82   1.6     ad #define X86_64_SET_GSBASE	X86_SET_GSBASE
     83  1.10   maxv #define X86_64_SET_FSBASE	X86_SET_FSBASE
     84   1.1     ad #endif
     85   1.1     ad 
     86   1.1     ad /*
     87   1.1     ad  * Architecture specific syscalls (x86)
     88   1.1     ad  */
     89   1.1     ad 
     90   1.1     ad struct _X86_SYSARCH_L(get_ldt_args) {
     91   1.1     ad 	int start;
     92   1.1     ad 	union descriptor *desc;
     93   1.1     ad 	int num;
     94   1.1     ad };
     95   1.1     ad 
     96   1.1     ad struct _X86_SYSARCH_L(set_ldt_args) {
     97   1.1     ad 	int start;
     98   1.1     ad 	union descriptor *desc;
     99   1.1     ad 	int num;
    100   1.1     ad };
    101   1.1     ad 
    102   1.1     ad struct _X86_SYSARCH_L(get_mtrr_args) {
    103   1.1     ad 	struct mtrr *mtrrp;
    104   1.1     ad 	int *n;
    105   1.1     ad };
    106   1.1     ad 
    107   1.1     ad struct _X86_SYSARCH_L(set_mtrr_args) {
    108   1.1     ad 	struct mtrr *mtrrp;
    109   1.1     ad 	int *n;
    110   1.1     ad };
    111   1.1     ad 
    112   1.1     ad struct _X86_SYSARCH_L(iopl_args) {
    113   1.1     ad 	int iopl;
    114   1.1     ad };
    115   1.1     ad 
    116   1.1     ad struct _X86_SYSARCH_L(get_ioperm_args) {
    117   1.1     ad 	u_long *iomap;
    118   1.1     ad };
    119   1.1     ad 
    120   1.1     ad struct _X86_SYSARCH_L(set_ioperm_args) {
    121   1.1     ad 	u_long *iomap;
    122   1.1     ad };
    123   1.1     ad 
    124   1.1     ad struct mtrr;
    125   1.1     ad 
    126   1.1     ad #ifdef _KERNEL
    127   1.1     ad int x86_iopl(struct lwp *, void *, register_t *);
    128   1.9    chs int x86_get_ldt1(struct lwp *, struct x86_get_ldt_args *, union descriptor *);
    129   1.9    chs int x86_set_ldt1(struct lwp *, struct x86_set_ldt_args *, union descriptor *);
    130   1.9    chs int x86_set_sdbase(void *, char, lwp_t *, bool);
    131   1.9    chs int x86_get_sdbase(void *, char);
    132   1.1     ad #else
    133   1.1     ad #include <sys/cdefs.h>
    134   1.1     ad __BEGIN_DECLS
    135   1.1     ad int _X86_SYSARCH_L(get_ldt)(int, union descriptor *, int);
    136   1.1     ad int _X86_SYSARCH_L(set_ldt)(int, union descriptor *, int);
    137   1.1     ad int _X86_SYSARCH_L(iopl)(int);
    138   1.1     ad int _X86_SYSARCH_L(set_mtrr)(struct mtrr *, int *);
    139   1.1     ad int _X86_SYSARCH_L(get_mtrr)(struct mtrr *, int *);
    140   1.1     ad int sysarch(int, void *);
    141   1.1     ad __END_DECLS
    142   1.1     ad #endif
    143   1.1     ad 
    144   1.1     ad #endif /* !_X86_SYSARCH_H_ */
    145