highmem.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. extern struct page *kmap_atomic_to_page(void *ptr);
  52. #endif /* !__ASSEMBLY__ */
  53. /*
  54. * The use of kmap_atomic/kunmap_atomic is discouraged - kmap/kunmap
  55. * gives a more generic (and caching) interface. But kmap_atomic can
  56. * be used in IRQ contexts, so in some (very limited) cases we need
  57. * it.
  58. */
  59. #define KMAP_ATOMIC_CACHE_DAMR 8
  60. #ifndef __ASSEMBLY__
  61. #define __kmap_atomic_primary(cached, paddr, ampr) \
  62. ({ \
  63. unsigned long damlr, dampr; \
  64. \
  65. dampr = paddr | xAMPRx_L | xAMPRx_M | xAMPRx_S | xAMPRx_SS_16Kb | xAMPRx_V; \
  66. \
  67. if (!cached) \
  68. asm volatile("movgs %0,dampr"#ampr :: "r"(dampr) : "memory"); \
  69. else \
  70. /* cache flush page attachment point */ \
  71. asm volatile("movgs %0,iampr"#ampr"\n" \
  72. "movgs %0,dampr"#ampr"\n" \
  73. :: "r"(dampr) : "memory" \
  74. ); \
  75. \
  76. asm("movsg damlr"#ampr",%0" : "=r"(damlr)); \
  77. \
  78. /*printk("DAMR"#ampr": PRIM sl=%d L=%08lx P=%08lx\n", type, damlr, dampr);*/ \
  79. \
  80. (void *) damlr; \
  81. })
  82. #define __kmap_atomic_secondary(slot, paddr) \
  83. ({ \
  84. unsigned long damlr = KMAP_ATOMIC_SECONDARY_FRAME + (slot) * PAGE_SIZE; \
  85. unsigned long dampr = paddr | xAMPRx_L | xAMPRx_M | xAMPRx_S | xAMPRx_SS_16Kb | xAMPRx_V; \
  86. \
  87. asm volatile("movgs %0,tplr \n" \
  88. "movgs %1,tppr \n" \
  89. "tlbpr %0,gr0,#2,#1" \
  90. : : "r"(damlr), "r"(dampr) : "memory"); \
  91. \
  92. /*printk("TLB: SECN sl=%d L=%08lx P=%08lx\n", slot, damlr, dampr);*/ \
  93. \
  94. (void *) damlr; \
  95. })
  96. static inline void *kmap_atomic_primary(struct page *page)
  97. {
  98. unsigned long paddr;
  99. pagefault_disable();
  100. paddr = page_to_phys(page);
  101. return __kmap_atomic_primary(1, paddr, 2);
  102. }
  103. #define __kunmap_atomic_primary(cached, ampr) \
  104. do { \
  105. asm volatile("movgs gr0,dampr"#ampr"\n" ::: "memory"); \
  106. if (cached) \
  107. asm volatile("movgs gr0,iampr"#ampr"\n" ::: "memory"); \
  108. } while(0)
  109. #define __kunmap_atomic_secondary(slot, vaddr) \
  110. do { \
  111. asm volatile("tlbpr %0,gr0,#4,#1" : : "r"(vaddr) : "memory"); \
  112. } while(0)
  113. static inline void kunmap_atomic_primary(void *kvaddr)
  114. {
  115. __kunmap_atomic_primary(1, 2);
  116. pagefault_enable();
  117. }
  118. void *kmap_atomic(struct page *page);
  119. void __kunmap_atomic(void *kvaddr);
  120. #endif /* !__ASSEMBLY__ */
  121. #endif /* __KERNEL__ */
  122. #endif /* _ASM_HIGHMEM_H */