Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: LGPL-2.0+ WITH Linux-syscall-note */
0002 /*  Generic MTRR (Memory Type Range Register) ioctls.
0003 
0004     Copyright (C) 1997-1999  Richard Gooch
0005 
0006     This library is free software; you can redistribute it and/or
0007     modify it under the terms of the GNU Library General Public
0008     License as published by the Free Software Foundation; either
0009     version 2 of the License, or (at your option) any later version.
0010 
0011     This library is distributed in the hope that it will be useful,
0012     but WITHOUT ANY WARRANTY; without even the implied warranty of
0013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014     Library General Public License for more details.
0015 
0016     You should have received a copy of the GNU Library General Public
0017     License along with this library; if not, write to the Free
0018     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
0019 
0020     Richard Gooch may be reached by email at  rgooch@atnf.csiro.au
0021     The postal address is:
0022       Richard Gooch, c/o ATNF, P. O. Box 76, Epping, N.S.W., 2121, Australia.
0023 */
0024 #ifndef _UAPI_ASM_X86_MTRR_H
0025 #define _UAPI_ASM_X86_MTRR_H
0026 
0027 #include <linux/types.h>
0028 #include <linux/ioctl.h>
0029 #include <linux/errno.h>
0030 
0031 #define MTRR_IOCTL_BASE 'M'
0032 
0033 /* Warning: this structure has a different order from i386
0034    on x86-64. The 32bit emulation code takes care of that.
0035    But you need to use this for 64bit, otherwise your X server
0036    will break. */
0037 
0038 #ifdef __i386__
0039 struct mtrr_sentry {
0040     unsigned long base;    /*  Base address     */
0041     unsigned int size;    /*  Size of region   */
0042     unsigned int type;     /*  Type of region   */
0043 };
0044 
0045 struct mtrr_gentry {
0046     unsigned int regnum;   /*  Register number  */
0047     unsigned long base;    /*  Base address     */
0048     unsigned int size;    /*  Size of region   */
0049     unsigned int type;     /*  Type of region   */
0050 };
0051 
0052 #else /* __i386__ */
0053 
0054 struct mtrr_sentry {
0055     __u64 base;     /*  Base address     */
0056     __u32 size;     /*  Size of region   */
0057     __u32 type;     /*  Type of region   */
0058 };
0059 
0060 struct mtrr_gentry {
0061     __u64 base;     /*  Base address     */
0062     __u32 size;     /*  Size of region   */
0063     __u32 regnum;       /*  Register number  */
0064     __u32 type;     /*  Type of region   */
0065     __u32 _pad;     /*  Unused       */
0066 };
0067 
0068 #endif /* !__i386__ */
0069 
0070 struct mtrr_var_range {
0071     __u32 base_lo;
0072     __u32 base_hi;
0073     __u32 mask_lo;
0074     __u32 mask_hi;
0075 };
0076 
0077 /* In the Intel processor's MTRR interface, the MTRR type is always held in
0078    an 8 bit field: */
0079 typedef __u8 mtrr_type;
0080 
0081 #define MTRR_NUM_FIXED_RANGES 88
0082 #define MTRR_MAX_VAR_RANGES 256
0083 
0084 struct mtrr_state_type {
0085     struct mtrr_var_range var_ranges[MTRR_MAX_VAR_RANGES];
0086     mtrr_type fixed_ranges[MTRR_NUM_FIXED_RANGES];
0087     unsigned char enabled;
0088     unsigned char have_fixed;
0089     mtrr_type def_type;
0090 };
0091 
0092 #define MTRRphysBase_MSR(reg) (0x200 + 2 * (reg))
0093 #define MTRRphysMask_MSR(reg) (0x200 + 2 * (reg) + 1)
0094 
0095 /*  These are the various ioctls  */
0096 #define MTRRIOC_ADD_ENTRY        _IOW(MTRR_IOCTL_BASE,  0, struct mtrr_sentry)
0097 #define MTRRIOC_SET_ENTRY        _IOW(MTRR_IOCTL_BASE,  1, struct mtrr_sentry)
0098 #define MTRRIOC_DEL_ENTRY        _IOW(MTRR_IOCTL_BASE,  2, struct mtrr_sentry)
0099 #define MTRRIOC_GET_ENTRY        _IOWR(MTRR_IOCTL_BASE, 3, struct mtrr_gentry)
0100 #define MTRRIOC_KILL_ENTRY       _IOW(MTRR_IOCTL_BASE,  4, struct mtrr_sentry)
0101 #define MTRRIOC_ADD_PAGE_ENTRY   _IOW(MTRR_IOCTL_BASE,  5, struct mtrr_sentry)
0102 #define MTRRIOC_SET_PAGE_ENTRY   _IOW(MTRR_IOCTL_BASE,  6, struct mtrr_sentry)
0103 #define MTRRIOC_DEL_PAGE_ENTRY   _IOW(MTRR_IOCTL_BASE,  7, struct mtrr_sentry)
0104 #define MTRRIOC_GET_PAGE_ENTRY   _IOWR(MTRR_IOCTL_BASE, 8, struct mtrr_gentry)
0105 #define MTRRIOC_KILL_PAGE_ENTRY  _IOW(MTRR_IOCTL_BASE,  9, struct mtrr_sentry)
0106 
0107 /* MTRR memory types, which are defined in SDM */
0108 #define MTRR_TYPE_UNCACHABLE 0
0109 #define MTRR_TYPE_WRCOMB     1
0110 /*#define MTRR_TYPE_         2*/
0111 /*#define MTRR_TYPE_         3*/
0112 #define MTRR_TYPE_WRTHROUGH  4
0113 #define MTRR_TYPE_WRPROT     5
0114 #define MTRR_TYPE_WRBACK     6
0115 #define MTRR_NUM_TYPES       7
0116 
0117 /*
0118  * Invalid MTRR memory type.  mtrr_type_lookup() returns this value when
0119  * MTRRs are disabled.  Note, this value is allocated from the reserved
0120  * values (0x7-0xff) of the MTRR memory types.
0121  */
0122 #define MTRR_TYPE_INVALID    0xff
0123 
0124 #endif /* _UAPI_ASM_X86_MTRR_H */