fixmap.h 1.9 KB

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