highmem.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * include/asm-xtensa/highmem.h
  3. *
  4. * This file is subject to the terms and conditions of the GNU General
  5. * Public License. See the file "COPYING" in the main directory of
  6. * this archive for more details.
  7. *
  8. * Copyright (C) 2003 - 2005 Tensilica Inc.
  9. * Copyright (C) 2014 Cadence Design Systems Inc.
  10. */
  11. #ifndef _XTENSA_HIGHMEM_H
  12. #define _XTENSA_HIGHMEM_H
  13. #include <linux/wait.h>
  14. #include <asm/cacheflush.h>
  15. #include <asm/fixmap.h>
  16. #include <asm/kmap_types.h>
  17. #include <asm/pgtable.h>
  18. #define PKMAP_BASE ((FIXADDR_START - \
  19. (LAST_PKMAP + 1) * PAGE_SIZE) & PMD_MASK)
  20. #define LAST_PKMAP (PTRS_PER_PTE * DCACHE_N_COLORS)
  21. #define LAST_PKMAP_MASK (LAST_PKMAP - 1)
  22. #define PKMAP_NR(virt) (((virt) - PKMAP_BASE) >> PAGE_SHIFT)
  23. #define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT))
  24. #define kmap_prot PAGE_KERNEL_EXEC
  25. #if DCACHE_WAY_SIZE > PAGE_SIZE
  26. #define get_pkmap_color get_pkmap_color
  27. static inline int get_pkmap_color(struct page *page)
  28. {
  29. return DCACHE_ALIAS(page_to_phys(page));
  30. }
  31. extern unsigned int last_pkmap_nr_arr[];
  32. static inline unsigned int get_next_pkmap_nr(unsigned int color)
  33. {
  34. last_pkmap_nr_arr[color] =
  35. (last_pkmap_nr_arr[color] + DCACHE_N_COLORS) & LAST_PKMAP_MASK;
  36. return last_pkmap_nr_arr[color] + color;
  37. }
  38. static inline int no_more_pkmaps(unsigned int pkmap_nr, unsigned int color)
  39. {
  40. return pkmap_nr < DCACHE_N_COLORS;
  41. }
  42. static inline int get_pkmap_entries_count(unsigned int color)
  43. {
  44. return LAST_PKMAP / DCACHE_N_COLORS;
  45. }
  46. extern wait_queue_head_t pkmap_map_wait_arr[];
  47. static inline wait_queue_head_t *get_pkmap_wait_queue_head(unsigned int color)
  48. {
  49. return pkmap_map_wait_arr + color;
  50. }
  51. #endif
  52. extern pte_t *pkmap_page_table;
  53. void *kmap_high(struct page *page);
  54. void kunmap_high(struct page *page);
  55. static inline void *kmap(struct page *page)
  56. {
  57. /* Check if this memory layout is broken because PKMAP overlaps
  58. * page table.
  59. */
  60. BUILD_BUG_ON(PKMAP_BASE <
  61. XCHAL_PAGE_TABLE_VADDR + XCHAL_PAGE_TABLE_SIZE);
  62. BUG_ON(in_interrupt());
  63. if (!PageHighMem(page))
  64. return page_address(page);
  65. return kmap_high(page);
  66. }
  67. static inline void kunmap(struct page *page)
  68. {
  69. BUG_ON(in_interrupt());
  70. if (!PageHighMem(page))
  71. return;
  72. kunmap_high(page);
  73. }
  74. static inline void flush_cache_kmaps(void)
  75. {
  76. flush_cache_all();
  77. }
  78. void *kmap_atomic(struct page *page);
  79. void __kunmap_atomic(void *kvaddr);
  80. void kmap_init(void);
  81. #endif