highmem.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #ifndef _ASM_HIGHMEM_H
  2. #define _ASM_HIGHMEM_H
  3. #include <asm/kmap_types.h>
  4. #define PKMAP_BASE (PAGE_OFFSET - PMD_SIZE)
  5. #define LAST_PKMAP PTRS_PER_PTE
  6. #define LAST_PKMAP_MASK (LAST_PKMAP - 1)
  7. #define PKMAP_NR(virt) (((virt) - PKMAP_BASE) >> PAGE_SHIFT)
  8. #define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT))
  9. #define kmap_prot PAGE_KERNEL
  10. #define flush_cache_kmaps() \
  11. do { \
  12. if (cache_is_vivt()) \
  13. flush_cache_all(); \
  14. } while (0)
  15. extern pte_t *pkmap_page_table;
  16. extern void *kmap_high(struct page *page);
  17. extern void kunmap_high(struct page *page);
  18. /*
  19. * The reason for kmap_high_get() is to ensure that the currently kmap'd
  20. * page usage count does not decrease to zero while we're using its
  21. * existing virtual mapping in an atomic context. With a VIVT cache this
  22. * is essential to do, but with a VIPT cache this is only an optimization
  23. * so not to pay the price of establishing a second mapping if an existing
  24. * one can be used. However, on platforms without hardware TLB maintenance
  25. * broadcast, we simply cannot use ARCH_NEEDS_KMAP_HIGH_GET at all since
  26. * the locking involved must also disable IRQs which is incompatible with
  27. * the IPI mechanism used by global TLB operations.
  28. */
  29. #define ARCH_NEEDS_KMAP_HIGH_GET
  30. #if defined(CONFIG_SMP) && defined(CONFIG_CPU_TLB_V6)
  31. #undef ARCH_NEEDS_KMAP_HIGH_GET
  32. #if defined(CONFIG_HIGHMEM) && defined(CONFIG_CPU_CACHE_VIVT)
  33. #error "The sum of features in your kernel config cannot be supported together"
  34. #endif
  35. #endif
  36. #ifdef ARCH_NEEDS_KMAP_HIGH_GET
  37. extern void *kmap_high_get(struct page *page);
  38. #else
  39. static inline void *kmap_high_get(struct page *page)
  40. {
  41. return NULL;
  42. }
  43. #endif
  44. /*
  45. * The following functions are already defined by <linux/highmem.h>
  46. * when CONFIG_HIGHMEM is not set.
  47. */
  48. #ifdef CONFIG_HIGHMEM
  49. extern void *kmap(struct page *page);
  50. extern void kunmap(struct page *page);
  51. extern void *kmap_atomic(struct page *page);
  52. extern void __kunmap_atomic(void *kvaddr);
  53. extern void *kmap_atomic_pfn(unsigned long pfn);
  54. extern struct page *kmap_atomic_to_page(const void *ptr);
  55. #endif
  56. #endif