1e2be04c7SGreg Kroah-Hartman /* SPDX-License-Identifier: LGPL-2.0+ WITH Linux-syscall-note */ 2af170c50SDavid Howells /* Generic MTRR (Memory Type Range Register) ioctls. 3af170c50SDavid Howells 4af170c50SDavid Howells Copyright (C) 1997-1999 Richard Gooch 5af170c50SDavid Howells 6af170c50SDavid Howells This library is free software; you can redistribute it and/or 7af170c50SDavid Howells modify it under the terms of the GNU Library General Public 8af170c50SDavid Howells License as published by the Free Software Foundation; either 9af170c50SDavid Howells version 2 of the License, or (at your option) any later version. 10af170c50SDavid Howells 11af170c50SDavid Howells This library is distributed in the hope that it will be useful, 12af170c50SDavid Howells but WITHOUT ANY WARRANTY; without even the implied warranty of 13af170c50SDavid Howells MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14af170c50SDavid Howells Library General Public License for more details. 15af170c50SDavid Howells 16af170c50SDavid Howells You should have received a copy of the GNU Library General Public 17af170c50SDavid Howells License along with this library; if not, write to the Free 18af170c50SDavid Howells Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19af170c50SDavid Howells 20af170c50SDavid Howells Richard Gooch may be reached by email at rgooch@atnf.csiro.au 21af170c50SDavid Howells The postal address is: 22af170c50SDavid Howells Richard Gooch, c/o ATNF, P. O. Box 76, Epping, N.S.W., 2121, Australia. 23af170c50SDavid Howells */ 24af170c50SDavid Howells #ifndef _UAPI_ASM_X86_MTRR_H 25af170c50SDavid Howells #define _UAPI_ASM_X86_MTRR_H 26af170c50SDavid Howells 27af170c50SDavid Howells #include <linux/types.h> 28af170c50SDavid Howells #include <linux/ioctl.h> 29af170c50SDavid Howells #include <linux/errno.h> 30af170c50SDavid Howells 31af170c50SDavid Howells #define MTRR_IOCTL_BASE 'M' 32af170c50SDavid Howells 33af170c50SDavid Howells /* Warning: this structure has a different order from i386 34af170c50SDavid Howells on x86-64. The 32bit emulation code takes care of that. 35af170c50SDavid Howells But you need to use this for 64bit, otherwise your X server 36af170c50SDavid Howells will break. */ 37af170c50SDavid Howells 38af170c50SDavid Howells #ifdef __i386__ 39af170c50SDavid Howells struct mtrr_sentry { 40af170c50SDavid Howells unsigned long base; /* Base address */ 41af170c50SDavid Howells unsigned int size; /* Size of region */ 42af170c50SDavid Howells unsigned int type; /* Type of region */ 43af170c50SDavid Howells }; 44af170c50SDavid Howells 45af170c50SDavid Howells struct mtrr_gentry { 46af170c50SDavid Howells unsigned int regnum; /* Register number */ 47af170c50SDavid Howells unsigned long base; /* Base address */ 48af170c50SDavid Howells unsigned int size; /* Size of region */ 49af170c50SDavid Howells unsigned int type; /* Type of region */ 50af170c50SDavid Howells }; 51af170c50SDavid Howells 52af170c50SDavid Howells #else /* __i386__ */ 53af170c50SDavid Howells 54af170c50SDavid Howells struct mtrr_sentry { 55af170c50SDavid Howells __u64 base; /* Base address */ 56af170c50SDavid Howells __u32 size; /* Size of region */ 57af170c50SDavid Howells __u32 type; /* Type of region */ 58af170c50SDavid Howells }; 59af170c50SDavid Howells 60af170c50SDavid Howells struct mtrr_gentry { 61af170c50SDavid Howells __u64 base; /* Base address */ 62af170c50SDavid Howells __u32 size; /* Size of region */ 63af170c50SDavid Howells __u32 regnum; /* Register number */ 64af170c50SDavid Howells __u32 type; /* Type of region */ 65af170c50SDavid Howells __u32 _pad; /* Unused */ 66af170c50SDavid Howells }; 67af170c50SDavid Howells 68af170c50SDavid Howells #endif /* !__i386__ */ 69af170c50SDavid Howells 70af170c50SDavid Howells struct mtrr_var_range { 71af170c50SDavid Howells __u32 base_lo; 72af170c50SDavid Howells __u32 base_hi; 73af170c50SDavid Howells __u32 mask_lo; 74af170c50SDavid Howells __u32 mask_hi; 75af170c50SDavid Howells }; 76af170c50SDavid Howells 77af170c50SDavid Howells /* In the Intel processor's MTRR interface, the MTRR type is always held in 78af170c50SDavid Howells an 8 bit field: */ 79af170c50SDavid Howells typedef __u8 mtrr_type; 80af170c50SDavid Howells 81af170c50SDavid Howells #define MTRR_NUM_FIXED_RANGES 88 82af170c50SDavid Howells #define MTRR_MAX_VAR_RANGES 256 83af170c50SDavid Howells 84af170c50SDavid Howells #define MTRRphysBase_MSR(reg) (0x200 + 2 * (reg)) 85af170c50SDavid Howells #define MTRRphysMask_MSR(reg) (0x200 + 2 * (reg) + 1) 86af170c50SDavid Howells 87af170c50SDavid Howells /* These are the various ioctls */ 88af170c50SDavid Howells #define MTRRIOC_ADD_ENTRY _IOW(MTRR_IOCTL_BASE, 0, struct mtrr_sentry) 89af170c50SDavid Howells #define MTRRIOC_SET_ENTRY _IOW(MTRR_IOCTL_BASE, 1, struct mtrr_sentry) 90af170c50SDavid Howells #define MTRRIOC_DEL_ENTRY _IOW(MTRR_IOCTL_BASE, 2, struct mtrr_sentry) 91af170c50SDavid Howells #define MTRRIOC_GET_ENTRY _IOWR(MTRR_IOCTL_BASE, 3, struct mtrr_gentry) 92af170c50SDavid Howells #define MTRRIOC_KILL_ENTRY _IOW(MTRR_IOCTL_BASE, 4, struct mtrr_sentry) 93af170c50SDavid Howells #define MTRRIOC_ADD_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 5, struct mtrr_sentry) 94af170c50SDavid Howells #define MTRRIOC_SET_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 6, struct mtrr_sentry) 95af170c50SDavid Howells #define MTRRIOC_DEL_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 7, struct mtrr_sentry) 96af170c50SDavid Howells #define MTRRIOC_GET_PAGE_ENTRY _IOWR(MTRR_IOCTL_BASE, 8, struct mtrr_gentry) 97af170c50SDavid Howells #define MTRRIOC_KILL_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 9, struct mtrr_sentry) 98af170c50SDavid Howells 993d3ca416SToshi Kani /* MTRR memory types, which are defined in SDM */ 100af170c50SDavid Howells #define MTRR_TYPE_UNCACHABLE 0 101af170c50SDavid Howells #define MTRR_TYPE_WRCOMB 1 102af170c50SDavid Howells /*#define MTRR_TYPE_ 2*/ 103af170c50SDavid Howells /*#define MTRR_TYPE_ 3*/ 104af170c50SDavid Howells #define MTRR_TYPE_WRTHROUGH 4 105af170c50SDavid Howells #define MTRR_TYPE_WRPROT 5 106af170c50SDavid Howells #define MTRR_TYPE_WRBACK 6 107af170c50SDavid Howells #define MTRR_NUM_TYPES 7 108af170c50SDavid Howells 1093d3ca416SToshi Kani /* 110*973df194SJuergen Gross * Invalid MTRR memory type. No longer used outside of MTRR code. 111*973df194SJuergen Gross * Note, this value is allocated from the reserved values (0x7-0xff) of 112*973df194SJuergen Gross * the MTRR memory types. 1133d3ca416SToshi Kani */ 1143d3ca416SToshi Kani #define MTRR_TYPE_INVALID 0xff 115af170c50SDavid Howells 116af170c50SDavid Howells #endif /* _UAPI_ASM_X86_MTRR_H */ 117