blob: eeb5caeb089b448252de2fd96366a09350afe166 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
venkatesh.pallipadi@intel.combe5a0c12010-02-10 11:57:06 -08002#ifndef __PAT_INTERNAL_H_
3#define __PAT_INTERNAL_H_
4
5extern int pat_debug_enable;
6
7#define dprintk(fmt, arg...) \
Luis R. Rodriguez9e765612015-05-26 10:28:11 +02008 do { if (pat_debug_enable) pr_info("x86/PAT: " fmt, ##arg); } while (0)
venkatesh.pallipadi@intel.combe5a0c12010-02-10 11:57:06 -08009
10struct memtype {
11 u64 start;
12 u64 end;
Pallipadi, Venkatesh9e41a492010-02-10 15:26:07 -080013 u64 subtree_max_end;
Juergen Grosse00c8cc2014-11-03 14:01:59 +010014 enum page_cache_mode type;
venkatesh.pallipadi@intel.combe5a0c12010-02-10 11:57:06 -080015 struct rb_node rb;
16};
17
Juergen Grosse00c8cc2014-11-03 14:01:59 +010018static inline char *cattr_name(enum page_cache_mode pcm)
venkatesh.pallipadi@intel.combe5a0c12010-02-10 11:57:06 -080019{
Juergen Grosse00c8cc2014-11-03 14:01:59 +010020 switch (pcm) {
21 case _PAGE_CACHE_MODE_UC: return "uncached";
22 case _PAGE_CACHE_MODE_UC_MINUS: return "uncached-minus";
23 case _PAGE_CACHE_MODE_WB: return "write-back";
24 case _PAGE_CACHE_MODE_WC: return "write-combining";
25 case _PAGE_CACHE_MODE_WT: return "write-through";
26 case _PAGE_CACHE_MODE_WP: return "write-protected";
27 default: return "broken";
venkatesh.pallipadi@intel.combe5a0c12010-02-10 11:57:06 -080028 }
29}
30
Pallipadi, Venkatesh9e41a492010-02-10 15:26:07 -080031#ifdef CONFIG_X86_PAT
32extern int rbt_memtype_check_insert(struct memtype *new,
Juergen Grosse00c8cc2014-11-03 14:01:59 +010033 enum page_cache_mode *new_type);
Xiaotian Feng20413f22010-05-26 09:51:10 +080034extern struct memtype *rbt_memtype_erase(u64 start, u64 end);
Pallipadi, Venkatesh9e41a492010-02-10 15:26:07 -080035extern struct memtype *rbt_memtype_lookup(u64 addr);
36extern int rbt_memtype_copy_nth_element(struct memtype *out, loff_t pos);
37#else
38static inline int rbt_memtype_check_insert(struct memtype *new,
Juergen Grosse00c8cc2014-11-03 14:01:59 +010039 enum page_cache_mode *new_type)
Pallipadi, Venkatesh9e41a492010-02-10 15:26:07 -080040{ return 0; }
Xiaotian Feng20413f22010-05-26 09:51:10 +080041static inline struct memtype *rbt_memtype_erase(u64 start, u64 end)
42{ return NULL; }
Pallipadi, Venkatesh9e41a492010-02-10 15:26:07 -080043static inline struct memtype *rbt_memtype_lookup(u64 addr)
44{ return NULL; }
45static inline int rbt_memtype_copy_nth_element(struct memtype *out, loff_t pos)
46{ return 0; }
47#endif
48
venkatesh.pallipadi@intel.combe5a0c12010-02-10 11:57:06 -080049#endif /* __PAT_INTERNAL_H_ */