Back to home page

OSCL-LXR

 
 

    


0001 /*  Generic MTRR (Memory Type Range Register) ioctls.
0002 
0003     Copyright (C) 1997-1999  Richard Gooch
0004 
0005     This library is free software; you can redistribute it and/or
0006     modify it under the terms of the GNU Library General Public
0007     License as published by the Free Software Foundation; either
0008     version 2 of the License, or (at your option) any later version.
0009 
0010     This library is distributed in the hope that it will be useful,
0011     but WITHOUT ANY WARRANTY; without even the implied warranty of
0012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013     Library General Public License for more details.
0014 
0015     You should have received a copy of the GNU Library General Public
0016     License along with this library; if not, write to the Free
0017     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
0018 
0019     Richard Gooch may be reached by email at  rgooch@atnf.csiro.au
0020     The postal address is:
0021       Richard Gooch, c/o ATNF, P. O. Box 76, Epping, N.S.W., 2121, Australia.
0022 */
0023 #ifndef _ASM_X86_MTRR_H
0024 #define _ASM_X86_MTRR_H
0025 
0026 #include <uapi/asm/mtrr.h>
0027 
0028 void mtrr_bp_init(void);
0029 
0030 /*
0031  * The following functions are for use by other drivers that cannot use
0032  * arch_phys_wc_add and arch_phys_wc_del.
0033  */
0034 # ifdef CONFIG_MTRR
0035 extern u8 mtrr_type_lookup(u64 addr, u64 end, u8 *uniform);
0036 extern void mtrr_save_fixed_ranges(void *);
0037 extern void mtrr_save_state(void);
0038 extern int mtrr_add(unsigned long base, unsigned long size,
0039             unsigned int type, bool increment);
0040 extern int mtrr_add_page(unsigned long base, unsigned long size,
0041              unsigned int type, bool increment);
0042 extern int mtrr_del(int reg, unsigned long base, unsigned long size);
0043 extern int mtrr_del_page(int reg, unsigned long base, unsigned long size);
0044 extern void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi);
0045 extern void mtrr_ap_init(void);
0046 extern void set_mtrr_aps_delayed_init(void);
0047 extern void mtrr_aps_init(void);
0048 extern void mtrr_bp_restore(void);
0049 extern int mtrr_trim_uncached_memory(unsigned long end_pfn);
0050 extern int amd_special_default_mtrr(void);
0051 #  else
0052 static inline u8 mtrr_type_lookup(u64 addr, u64 end, u8 *uniform)
0053 {
0054     /*
0055      * Return no-MTRRs:
0056      */
0057     return MTRR_TYPE_INVALID;
0058 }
0059 #define mtrr_save_fixed_ranges(arg) do {} while (0)
0060 #define mtrr_save_state() do {} while (0)
0061 static inline int mtrr_add(unsigned long base, unsigned long size,
0062                unsigned int type, bool increment)
0063 {
0064     return -ENODEV;
0065 }
0066 static inline int mtrr_add_page(unsigned long base, unsigned long size,
0067                 unsigned int type, bool increment)
0068 {
0069     return -ENODEV;
0070 }
0071 static inline int mtrr_del(int reg, unsigned long base, unsigned long size)
0072 {
0073     return -ENODEV;
0074 }
0075 static inline int mtrr_del_page(int reg, unsigned long base, unsigned long size)
0076 {
0077     return -ENODEV;
0078 }
0079 static inline int mtrr_trim_uncached_memory(unsigned long end_pfn)
0080 {
0081     return 0;
0082 }
0083 static inline void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi)
0084 {
0085 }
0086 #define mtrr_ap_init() do {} while (0)
0087 #define set_mtrr_aps_delayed_init() do {} while (0)
0088 #define mtrr_aps_init() do {} while (0)
0089 #define mtrr_bp_restore() do {} while (0)
0090 #  endif
0091 
0092 #ifdef CONFIG_COMPAT
0093 #include <linux/compat.h>
0094 
0095 struct mtrr_sentry32 {
0096     compat_ulong_t base;    /*  Base address     */
0097     compat_uint_t size;    /*  Size of region   */
0098     compat_uint_t type;     /*  Type of region   */
0099 };
0100 
0101 struct mtrr_gentry32 {
0102     compat_ulong_t regnum;   /*  Register number  */
0103     compat_uint_t base;    /*  Base address     */
0104     compat_uint_t size;    /*  Size of region   */
0105     compat_uint_t type;     /*  Type of region   */
0106 };
0107 
0108 #define MTRR_IOCTL_BASE 'M'
0109 
0110 #define MTRRIOC32_ADD_ENTRY      _IOW(MTRR_IOCTL_BASE,  0, struct mtrr_sentry32)
0111 #define MTRRIOC32_SET_ENTRY      _IOW(MTRR_IOCTL_BASE,  1, struct mtrr_sentry32)
0112 #define MTRRIOC32_DEL_ENTRY      _IOW(MTRR_IOCTL_BASE,  2, struct mtrr_sentry32)
0113 #define MTRRIOC32_GET_ENTRY      _IOWR(MTRR_IOCTL_BASE, 3, struct mtrr_gentry32)
0114 #define MTRRIOC32_KILL_ENTRY     _IOW(MTRR_IOCTL_BASE,  4, struct mtrr_sentry32)
0115 #define MTRRIOC32_ADD_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE,  5, struct mtrr_sentry32)
0116 #define MTRRIOC32_SET_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE,  6, struct mtrr_sentry32)
0117 #define MTRRIOC32_DEL_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE,  7, struct mtrr_sentry32)
0118 #define MTRRIOC32_GET_PAGE_ENTRY _IOWR(MTRR_IOCTL_BASE, 8, struct mtrr_gentry32)
0119 #define MTRRIOC32_KILL_PAGE_ENTRY       \
0120                  _IOW(MTRR_IOCTL_BASE,  9, struct mtrr_sentry32)
0121 #endif /* CONFIG_COMPAT */
0122 
0123 /* Bit fields for enabled in struct mtrr_state_type */
0124 #define MTRR_STATE_MTRR_FIXED_ENABLED   0x01
0125 #define MTRR_STATE_MTRR_ENABLED     0x02
0126 
0127 #endif /* _ASM_X86_MTRR_H */