1 #ifndef __PAT_INTERNAL_H_
2 #define __PAT_INTERNAL_H_
3
4 extern int pat_debug_enable;
5
6 #define dprintk(fmt, arg...) \
7 do { if (pat_debug_enable) pr_info("x86/PAT: " fmt, ##arg); } while (0)
8
9 struct memtype {
10 u64 start;
11 u64 end;
12 u64 subtree_max_end;
13 enum page_cache_mode type;
14 struct rb_node rb;
15 };
16
cattr_name(enum page_cache_mode pcm)17 static inline char *cattr_name(enum page_cache_mode pcm)
18 {
19 switch (pcm) {
20 case _PAGE_CACHE_MODE_UC: return "uncached";
21 case _PAGE_CACHE_MODE_UC_MINUS: return "uncached-minus";
22 case _PAGE_CACHE_MODE_WB: return "write-back";
23 case _PAGE_CACHE_MODE_WC: return "write-combining";
24 case _PAGE_CACHE_MODE_WT: return "write-through";
25 case _PAGE_CACHE_MODE_WP: return "write-protected";
26 default: return "broken";
27 }
28 }
29
30 #ifdef CONFIG_X86_PAT
31 extern int rbt_memtype_check_insert(struct memtype *new,
32 enum page_cache_mode *new_type);
33 extern struct memtype *rbt_memtype_erase(u64 start, u64 end);
34 extern struct memtype *rbt_memtype_lookup(u64 addr);
35 extern int rbt_memtype_copy_nth_element(struct memtype *out, loff_t pos);
36 #else
rbt_memtype_check_insert(struct memtype * new,enum page_cache_mode * new_type)37 static inline int rbt_memtype_check_insert(struct memtype *new,
38 enum page_cache_mode *new_type)
39 { return 0; }
rbt_memtype_erase(u64 start,u64 end)40 static inline struct memtype *rbt_memtype_erase(u64 start, u64 end)
41 { return NULL; }
rbt_memtype_lookup(u64 addr)42 static inline struct memtype *rbt_memtype_lookup(u64 addr)
43 { return NULL; }
rbt_memtype_copy_nth_element(struct memtype * out,loff_t pos)44 static inline int rbt_memtype_copy_nth_element(struct memtype *out, loff_t pos)
45 { return 0; }
46 #endif
47
48 #endif /* __PAT_INTERNAL_H_ */
49