pgtsun4.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. * pgtsun4.h: Sun4 specific pgtable.h defines and code.
  3. *
  4. * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  5. * Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
  6. */
  7. #ifndef _SPARC_PGTSUN4C_H
  8. #define _SPARC_PGTSUN4C_H
  9. #include <asm/contregs.h>
  10. /* PMD_SHIFT determines the size of the area a second-level page table can map */
  11. #define SUN4C_PMD_SHIFT 23
  12. /* PGDIR_SHIFT determines what a third-level page table entry can map */
  13. #define SUN4C_PGDIR_SHIFT 23
  14. #define SUN4C_PGDIR_SIZE (1UL << SUN4C_PGDIR_SHIFT)
  15. #define SUN4C_PGDIR_MASK (~(SUN4C_PGDIR_SIZE-1))
  16. #define SUN4C_PGDIR_ALIGN(addr) (((addr)+SUN4C_PGDIR_SIZE-1)&SUN4C_PGDIR_MASK)
  17. /* To represent how the sun4c mmu really lays things out. */
  18. #define SUN4C_REAL_PGDIR_SHIFT 18
  19. #define SUN4C_REAL_PGDIR_SIZE (1UL << SUN4C_REAL_PGDIR_SHIFT)
  20. #define SUN4C_REAL_PGDIR_MASK (~(SUN4C_REAL_PGDIR_SIZE-1))
  21. #define SUN4C_REAL_PGDIR_ALIGN(addr) (((addr)+SUN4C_REAL_PGDIR_SIZE-1)&SUN4C_REAL_PGDIR_MASK)
  22. /* 19 bit PFN on sun4 */
  23. #define SUN4C_PFN_MASK 0x7ffff
  24. /* Don't increase these unless the structures in sun4c.c are fixed */
  25. #define SUN4C_MAX_SEGMAPS 256
  26. #define SUN4C_MAX_CONTEXTS 16
  27. /*
  28. * To be efficient, and not have to worry about allocating such
  29. * a huge pgd, we make the kernel sun4c tables each hold 1024
  30. * entries and the pgd similarly just like the i386 tables.
  31. */
  32. #define SUN4C_PTRS_PER_PTE 1024
  33. #define SUN4C_PTRS_PER_PMD 1
  34. #define SUN4C_PTRS_PER_PGD 1024
  35. /*
  36. * Sparc SUN4C pte fields.
  37. */
  38. #define _SUN4C_PAGE_VALID 0x80000000
  39. #define _SUN4C_PAGE_SILENT_READ 0x80000000 /* synonym */
  40. #define _SUN4C_PAGE_DIRTY 0x40000000
  41. #define _SUN4C_PAGE_SILENT_WRITE 0x40000000 /* synonym */
  42. #define _SUN4C_PAGE_PRIV 0x20000000 /* privileged page */
  43. #define _SUN4C_PAGE_NOCACHE 0x10000000 /* non-cacheable page */
  44. #define _SUN4C_PAGE_PRESENT 0x08000000 /* implemented in software */
  45. #define _SUN4C_PAGE_IO 0x04000000 /* I/O page */
  46. #define _SUN4C_PAGE_FILE 0x02000000 /* implemented in software */
  47. #define _SUN4C_PAGE_READ 0x00800000 /* implemented in software */
  48. #define _SUN4C_PAGE_WRITE 0x00400000 /* implemented in software */
  49. #define _SUN4C_PAGE_ACCESSED 0x00200000 /* implemented in software */
  50. #define _SUN4C_PAGE_MODIFIED 0x00100000 /* implemented in software */
  51. #define _SUN4C_READABLE (_SUN4C_PAGE_READ|_SUN4C_PAGE_SILENT_READ|\
  52. _SUN4C_PAGE_ACCESSED)
  53. #define _SUN4C_WRITEABLE (_SUN4C_PAGE_WRITE|_SUN4C_PAGE_SILENT_WRITE|\
  54. _SUN4C_PAGE_MODIFIED)
  55. #define _SUN4C_PAGE_CHG_MASK (0xffff|_SUN4C_PAGE_ACCESSED|_SUN4C_PAGE_MODIFIED)
  56. #define SUN4C_PAGE_NONE __pgprot(_SUN4C_PAGE_PRESENT)
  57. #define SUN4C_PAGE_SHARED __pgprot(_SUN4C_PAGE_PRESENT|_SUN4C_READABLE|\
  58. _SUN4C_PAGE_WRITE)
  59. #define SUN4C_PAGE_COPY __pgprot(_SUN4C_PAGE_PRESENT|_SUN4C_READABLE)
  60. #define SUN4C_PAGE_READONLY __pgprot(_SUN4C_PAGE_PRESENT|_SUN4C_READABLE)
  61. #define SUN4C_PAGE_KERNEL __pgprot(_SUN4C_READABLE|_SUN4C_WRITEABLE|\
  62. _SUN4C_PAGE_DIRTY|_SUN4C_PAGE_PRIV)
  63. /* SUN4C swap entry encoding
  64. *
  65. * We use 5 bits for the type and 19 for the offset. This gives us
  66. * 32 swapfiles of 4GB each. Encoding looks like:
  67. *
  68. * RRRRRRRRooooooooooooooooooottttt
  69. * fedcba9876543210fedcba9876543210
  70. *
  71. * The top 8 bits are reserved for protection and status bits, especially
  72. * FILE and PRESENT.
  73. */
  74. #define SUN4C_SWP_TYPE_MASK 0x1f
  75. #define SUN4C_SWP_OFF_MASK 0x7ffff
  76. #define SUN4C_SWP_OFF_SHIFT 5
  77. #ifndef __ASSEMBLY__
  78. static inline unsigned long sun4c_get_synchronous_error(void)
  79. {
  80. unsigned long sync_err;
  81. __asm__ __volatile__("lda [%1] %2, %0\n\t" :
  82. "=r" (sync_err) :
  83. "r" (AC_SYNC_ERR), "i" (ASI_CONTROL));
  84. return sync_err;
  85. }
  86. static inline unsigned long sun4c_get_synchronous_address(void)
  87. {
  88. unsigned long sync_addr;
  89. __asm__ __volatile__("lda [%1] %2, %0\n\t" :
  90. "=r" (sync_addr) :
  91. "r" (AC_SYNC_VA), "i" (ASI_CONTROL));
  92. return sync_addr;
  93. }
  94. /* SUN4 pte, segmap, and context manipulation */
  95. static inline unsigned long sun4c_get_segmap(unsigned long addr)
  96. {
  97. register unsigned long entry;
  98. __asm__ __volatile__("\n\tlduha [%1] %2, %0\n\t" :
  99. "=r" (entry) :
  100. "r" (addr), "i" (ASI_SEGMAP));
  101. return entry;
  102. }
  103. static inline void sun4c_put_segmap(unsigned long addr, unsigned long entry)
  104. {
  105. __asm__ __volatile__("\n\tstha %1, [%0] %2; nop; nop; nop;\n\t" : :
  106. "r" (addr), "r" (entry),
  107. "i" (ASI_SEGMAP)
  108. : "memory");
  109. }
  110. static inline unsigned long sun4c_get_pte(unsigned long addr)
  111. {
  112. register unsigned long entry;
  113. __asm__ __volatile__("\n\tlda [%1] %2, %0\n\t" :
  114. "=r" (entry) :
  115. "r" (addr), "i" (ASI_PTE));
  116. return entry;
  117. }
  118. static inline void sun4c_put_pte(unsigned long addr, unsigned long entry)
  119. {
  120. __asm__ __volatile__("\n\tsta %1, [%0] %2; nop; nop; nop;\n\t" : :
  121. "r" (addr),
  122. "r" ((entry & ~(_SUN4C_PAGE_PRESENT))), "i" (ASI_PTE)
  123. : "memory");
  124. }
  125. static inline int sun4c_get_context(void)
  126. {
  127. register int ctx;
  128. __asm__ __volatile__("\n\tlduba [%1] %2, %0\n\t" :
  129. "=r" (ctx) :
  130. "r" (AC_CONTEXT), "i" (ASI_CONTROL));
  131. return ctx;
  132. }
  133. static inline int sun4c_set_context(int ctx)
  134. {
  135. __asm__ __volatile__("\n\tstba %0, [%1] %2; nop; nop; nop;\n\t" : :
  136. "r" (ctx), "r" (AC_CONTEXT), "i" (ASI_CONTROL)
  137. : "memory");
  138. return ctx;
  139. }
  140. #endif /* !(__ASSEMBLY__) */
  141. #endif /* !(_SPARC_PGTSUN4_H) */