/* SPDX-License-Identifier: LGPL-2.0+ WITH Linux-syscall-note */1/* Generic MTRR (Memory Type Range Register) ioctls.23Copyright (C) 1997-1999 Richard Gooch45This library is free software; you can redistribute it and/or6modify it under the terms of the GNU Library General Public7License as published by the Free Software Foundation; either8version 2 of the License, or (at your option) any later version.910This library is distributed in the hope that it will be useful,11but WITHOUT ANY WARRANTY; without even the implied warranty of12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU13Library General Public License for more details.1415You should have received a copy of the GNU Library General Public16License along with this library; if not, write to the Free17Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.1819Richard Gooch may be reached by email at [email protected]20The postal address is:21Richard Gooch, c/o ATNF, P. O. Box 76, Epping, N.S.W., 2121, Australia.22*/23#ifndef _UAPI_ASM_X86_MTRR_H24#define _UAPI_ASM_X86_MTRR_H2526#include <linux/types.h>27#include <linux/ioctl.h>28#include <linux/errno.h>2930#define MTRR_IOCTL_BASE 'M'3132/* Warning: this structure has a different order from i38633on x86-64. The 32bit emulation code takes care of that.34But you need to use this for 64bit, otherwise your X server35will break. */3637#ifdef __i386__38struct mtrr_sentry {39unsigned long base; /* Base address */40unsigned int size; /* Size of region */41unsigned int type; /* Type of region */42};4344struct mtrr_gentry {45unsigned int regnum; /* Register number */46unsigned long base; /* Base address */47unsigned int size; /* Size of region */48unsigned int type; /* Type of region */49};5051#else /* __i386__ */5253struct mtrr_sentry {54__u64 base; /* Base address */55__u32 size; /* Size of region */56__u32 type; /* Type of region */57};5859struct mtrr_gentry {60__u64 base; /* Base address */61__u32 size; /* Size of region */62__u32 regnum; /* Register number */63__u32 type; /* Type of region */64__u32 _pad; /* Unused */65};6667#endif /* !__i386__ */6869struct mtrr_var_range {70__u32 base_lo;71__u32 base_hi;72__u32 mask_lo;73__u32 mask_hi;74};7576/* In the Intel processor's MTRR interface, the MTRR type is always held in77an 8 bit field: */78typedef __u8 mtrr_type;7980#define MTRR_NUM_FIXED_RANGES 8881#define MTRR_MAX_VAR_RANGES 2568283#define MTRRphysBase_MSR(reg) (0x200 + 2 * (reg))84#define MTRRphysMask_MSR(reg) (0x200 + 2 * (reg) + 1)8586/* These are the various ioctls */87#define MTRRIOC_ADD_ENTRY _IOW(MTRR_IOCTL_BASE, 0, struct mtrr_sentry)88#define MTRRIOC_SET_ENTRY _IOW(MTRR_IOCTL_BASE, 1, struct mtrr_sentry)89#define MTRRIOC_DEL_ENTRY _IOW(MTRR_IOCTL_BASE, 2, struct mtrr_sentry)90#define MTRRIOC_GET_ENTRY _IOWR(MTRR_IOCTL_BASE, 3, struct mtrr_gentry)91#define MTRRIOC_KILL_ENTRY _IOW(MTRR_IOCTL_BASE, 4, struct mtrr_sentry)92#define MTRRIOC_ADD_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 5, struct mtrr_sentry)93#define MTRRIOC_SET_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 6, struct mtrr_sentry)94#define MTRRIOC_DEL_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 7, struct mtrr_sentry)95#define MTRRIOC_GET_PAGE_ENTRY _IOWR(MTRR_IOCTL_BASE, 8, struct mtrr_gentry)96#define MTRRIOC_KILL_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 9, struct mtrr_sentry)9798/* MTRR memory types, which are defined in SDM */99#define MTRR_TYPE_UNCACHABLE 0100#define MTRR_TYPE_WRCOMB 1101/*#define MTRR_TYPE_ 2*/102/*#define MTRR_TYPE_ 3*/103#define MTRR_TYPE_WRTHROUGH 4104#define MTRR_TYPE_WRPROT 5105#define MTRR_TYPE_WRBACK 6106#define MTRR_NUM_TYPES 7107108/*109* Invalid MTRR memory type. No longer used outside of MTRR code.110* Note, this value is allocated from the reserved values (0x7-0xff) of111* the MTRR memory types.112*/113#define MTRR_TYPE_INVALID 0xff114115#endif /* _UAPI_ASM_X86_MTRR_H */116117118