mtrr.h 4.1 KB

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