H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 1 | #ifndef _ASM_X86_FIXMAP_H |
| 2 | #define _ASM_X86_FIXMAP_H |
Ingo Molnar | 3ec9678 | 2008-04-25 18:25:25 +0200 | [diff] [blame] | 3 | |
Thomas Gleixner | 96a388d | 2007-10-11 11:20:03 +0200 | [diff] [blame] | 4 | #ifdef CONFIG_X86_32 |
| 5 | # include "fixmap_32.h" |
| 6 | #else |
| 7 | # include "fixmap_64.h" |
| 8 | #endif |
Ingo Molnar | 3ec9678 | 2008-04-25 18:25:25 +0200 | [diff] [blame] | 9 | |
Jeremy Fitzhardinge | 7c7e6e0 | 2008-06-17 11:41:54 -0700 | [diff] [blame] | 10 | extern int fixmaps_set; |
| 11 | |
Keith Packard | fd94093 | 2008-10-30 19:37:09 -0700 | [diff] [blame^] | 12 | extern pte_t *kmap_pte; |
| 13 | extern pgprot_t kmap_prot; |
| 14 | extern pte_t *pkmap_page_table; |
| 15 | |
Jeremy Fitzhardinge | aeaaa59 | 2008-06-17 11:42:01 -0700 | [diff] [blame] | 16 | void __native_set_fixmap(enum fixed_addresses idx, pte_t pte); |
| 17 | void native_set_fixmap(enum fixed_addresses idx, |
| 18 | unsigned long phys, pgprot_t flags); |
| 19 | |
| 20 | #ifndef CONFIG_PARAVIRT |
| 21 | static inline void __set_fixmap(enum fixed_addresses idx, |
| 22 | unsigned long phys, pgprot_t flags) |
| 23 | { |
| 24 | native_set_fixmap(idx, phys, flags); |
| 25 | } |
| 26 | #endif |
| 27 | |
Jeremy Fitzhardinge | 944256e | 2008-06-17 11:41:49 -0700 | [diff] [blame] | 28 | #define set_fixmap(idx, phys) \ |
| 29 | __set_fixmap(idx, phys, PAGE_KERNEL) |
| 30 | |
| 31 | /* |
| 32 | * Some hardware wants to get fixmapped without caching. |
| 33 | */ |
| 34 | #define set_fixmap_nocache(idx, phys) \ |
| 35 | __set_fixmap(idx, phys, PAGE_KERNEL_NOCACHE) |
| 36 | |
Ingo Molnar | 3ec9678 | 2008-04-25 18:25:25 +0200 | [diff] [blame] | 37 | #define clear_fixmap(idx) \ |
| 38 | __set_fixmap(idx, 0, __pgprot(0)) |
| 39 | |
Jeremy Fitzhardinge | 944256e | 2008-06-17 11:41:49 -0700 | [diff] [blame] | 40 | #define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT)) |
| 41 | #define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT) |
| 42 | |
| 43 | extern void __this_fixmap_does_not_exist(void); |
| 44 | |
| 45 | /* |
| 46 | * 'index to address' translation. If anyone tries to use the idx |
| 47 | * directly without translation, we catch the bug with a NULL-deference |
| 48 | * kernel oops. Illegal ranges of incoming indices are caught too. |
| 49 | */ |
| 50 | static __always_inline unsigned long fix_to_virt(const unsigned int idx) |
| 51 | { |
| 52 | /* |
| 53 | * this branch gets completely eliminated after inlining, |
| 54 | * except when someone tries to use fixaddr indices in an |
| 55 | * illegal way. (such as mixing up address types or using |
| 56 | * out-of-range indices). |
| 57 | * |
| 58 | * If it doesn't get removed, the linker will complain |
| 59 | * loudly with a reasonably clear error message.. |
| 60 | */ |
| 61 | if (idx >= __end_of_fixed_addresses) |
| 62 | __this_fixmap_does_not_exist(); |
| 63 | |
| 64 | return __fix_to_virt(idx); |
| 65 | } |
| 66 | |
| 67 | static inline unsigned long virt_to_fix(const unsigned long vaddr) |
| 68 | { |
| 69 | BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START); |
| 70 | return __virt_to_fix(vaddr); |
| 71 | } |
H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 72 | #endif /* _ASM_X86_FIXMAP_H */ |