pgtsun4c.h 5.3 KB

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