highmem.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /* highmem.h: virtual kernel memory mappings for high memory
  2. *
  3. * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. * - Derived from include/asm-i386/highmem.h
  6. *
  7. * See Documentation/frv/mmu-layout.txt for more information.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version
  12. * 2 of the License, or (at your option) any later version.
  13. */
  14. #ifndef _ASM_HIGHMEM_H
  15. #define _ASM_HIGHMEM_H
  16. #ifdef __KERNEL__
  17. #include <linux/init.h>
  18. #include <linux/highmem.h>
  19. #include <asm/mem-layout.h>
  20. #include <asm/spr-regs.h>
  21. #include <asm/mb-regs.h>
  22. #define NR_TLB_LINES 64 /* number of lines in the TLB */
  23. #ifndef __ASSEMBLY__
  24. #include <linux/interrupt.h>
  25. #include <asm/kmap_types.h>
  26. #include <asm/pgtable.h>
  27. #ifdef CONFIG_DEBUG_HIGHMEM
  28. #define HIGHMEM_DEBUG 1
  29. #else
  30. #define HIGHMEM_DEBUG 0
  31. #endif
  32. /* declarations for highmem.c */
  33. extern unsigned long highstart_pfn, highend_pfn;
  34. #define kmap_prot PAGE_KERNEL
  35. #define kmap_pte ______kmap_pte_in_TLB
  36. extern pte_t *pkmap_page_table;
  37. #define flush_cache_kmaps() do { } while (0)
  38. /*
  39. * Right now we initialize only a single pte table. It can be extended
  40. * easily, subsequent pte tables have to be allocated in one physical
  41. * chunk of RAM.
  42. */
  43. #define LAST_PKMAP PTRS_PER_PTE
  44. #define LAST_PKMAP_MASK (LAST_PKMAP - 1)
  45. #define PKMAP_NR(virt) ((virt - PKMAP_BASE) >> PAGE_SHIFT)
  46. #define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT))
  47. extern void *kmap_high(struct page *page);
  48. extern void kunmap_high(struct page *page);
  49. extern void *kmap(struct page *page);
  50. extern void kunmap(struct page *page);
  51. #endif /* !__ASSEMBLY__ */
  52. /*
  53. * The use of kmap_atomic/kunmap_atomic is discouraged - kmap/kunmap
  54. * gives a more generic (and caching) interface. But kmap_atomic can
  55. * be used in IRQ contexts, so in some (very limited) cases we need
  56. * it.
  57. */
  58. #define KMAP_ATOMIC_CACHE_DAMR 8
  59. #ifndef __ASSEMBLY__
  60. #define __kmap_atomic_primary(cached, paddr, ampr) \
  61. ({ \
  62. unsigned long damlr, dampr; \
  63. \
  64. dampr = paddr | xAMPRx_L | xAMPRx_M | xAMPRx_S | xAMPRx_SS_16Kb | xAMPRx_V; \
  65. \
  66. if (!cached) \
  67. asm volatile("movgs %0,dampr"#ampr :: "r"(dampr) : "memory"); \
  68. else \
  69. /* cache flush page attachment point */ \
  70. asm volatile("movgs %0,iampr"#ampr"\n" \
  71. "movgs %0,dampr"#ampr"\n" \
  72. :: "r"(dampr) : "memory" \
  73. ); \
  74. \
  75. asm("movsg damlr"#ampr",%0" : "=r"(damlr)); \
  76. \
  77. /*printk("DAMR"#ampr": PRIM sl=%d L=%08lx P=%08lx\n", type, damlr, dampr);*/ \
  78. \
  79. (void *) damlr; \
  80. })
  81. #define __kmap_atomic_secondary(slot, paddr) \
  82. ({ \
  83. unsigned long damlr = KMAP_ATOMIC_SECONDARY_FRAME + (slot) * PAGE_SIZE; \
  84. unsigned long dampr = paddr | xAMPRx_L | xAMPRx_M | xAMPRx_S | xAMPRx_SS_16Kb | xAMPRx_V; \
  85. \
  86. asm volatile("movgs %0,tplr \n" \
  87. "movgs %1,tppr \n" \
  88. "tlbpr %0,gr0,#2,#1" \
  89. : : "r"(damlr), "r"(dampr) : "memory"); \
  90. \
  91. /*printk("TLB: SECN sl=%d L=%08lx P=%08lx\n", slot, damlr, dampr);*/ \
  92. \
  93. (void *) damlr; \
  94. })
  95. static inline void *kmap_atomic_primary(struct page *page)
  96. {
  97. unsigned long paddr;
  98. pagefault_disable();
  99. paddr = page_to_phys(page);
  100. return __kmap_atomic_primary(1, paddr, 2);
  101. }
  102. #define __kunmap_atomic_primary(cached, ampr) \
  103. do { \
  104. asm volatile("movgs gr0,dampr"#ampr"\n" ::: "memory"); \
  105. if (cached) \
  106. asm volatile("movgs gr0,iampr"#ampr"\n" ::: "memory"); \
  107. } while(0)
  108. #define __kunmap_atomic_secondary(slot, vaddr) \
  109. do { \
  110. asm volatile("tlbpr %0,gr0,#4,#1" : : "r"(vaddr) : "memory"); \
  111. } while(0)
  112. static inline void kunmap_atomic_primary(void *kvaddr)
  113. {
  114. __kunmap_atomic_primary(1, 2);
  115. pagefault_enable();
  116. }
  117. void *kmap_atomic(struct page *page);
  118. void __kunmap_atomic(void *kvaddr);
  119. #endif /* !__ASSEMBLY__ */
  120. #endif /* __KERNEL__ */
  121. #endif /* _ASM_HIGHMEM_H */