pgtsun4c.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:5k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /* $Id: pgtsun4c.h,v 1.37 2000/06/05 06:08:46 anton Exp $
  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. #define SUN4C_PMD_SIZE        (1UL << SUN4C_PMD_SHIFT)
  12. #define SUN4C_PMD_MASK        (~(SUN4C_PMD_SIZE-1))
  13. #define SUN4C_PMD_ALIGN(addr) (((addr)+SUN4C_PMD_SIZE-1)&SUN4C_PMD_MASK)
  14. /* PGDIR_SHIFT determines what a third-level page table entry can map */
  15. #define SUN4C_PGDIR_SHIFT       22
  16. #define SUN4C_PGDIR_SIZE        (1UL << SUN4C_PGDIR_SHIFT)
  17. #define SUN4C_PGDIR_MASK        (~(SUN4C_PGDIR_SIZE-1))
  18. #define SUN4C_PGDIR_ALIGN(addr) (((addr)+SUN4C_PGDIR_SIZE-1)&SUN4C_PGDIR_MASK)
  19. /* To represent how the sun4c mmu really lays things out. */
  20. #define SUN4C_REAL_PGDIR_SHIFT       18
  21. #define SUN4C_REAL_PGDIR_SIZE        (1UL << SUN4C_REAL_PGDIR_SHIFT)
  22. #define SUN4C_REAL_PGDIR_MASK        (~(SUN4C_REAL_PGDIR_SIZE-1))
  23. #define SUN4C_REAL_PGDIR_ALIGN(addr) (((addr)+SUN4C_REAL_PGDIR_SIZE-1)&SUN4C_REAL_PGDIR_MASK)
  24. /* 16 bit PFN on sun4c */
  25. #define SUN4C_PFN_MASK 0xffff
  26. /* Don't increase these unless the structures in sun4c.c are fixed */
  27. #define SUN4C_MAX_SEGMAPS 256
  28. #define SUN4C_MAX_CONTEXTS 16
  29. /*
  30.  * To be efficient, and not have to worry about allocating such
  31.  * a huge pgd, we make the kernel sun4c tables each hold 1024
  32.  * entries and the pgd similarly just like the i386 tables.
  33.  */
  34. #define SUN4C_PTRS_PER_PTE    1024
  35. #define SUN4C_PTRS_PER_PMD    1
  36. #define SUN4C_PTRS_PER_PGD    1024
  37. /*
  38.  * Sparc SUN4C pte fields.
  39.  */
  40. #define _SUN4C_PAGE_VALID        0x80000000
  41. #define _SUN4C_PAGE_SILENT_READ  0x80000000   /* synonym */
  42. #define _SUN4C_PAGE_DIRTY        0x40000000
  43. #define _SUN4C_PAGE_SILENT_WRITE 0x40000000   /* synonym */
  44. #define _SUN4C_PAGE_PRIV         0x20000000   /* privileged page */
  45. #define _SUN4C_PAGE_NOCACHE      0x10000000   /* non-cacheable page */
  46. #define _SUN4C_PAGE_PRESENT      0x08000000   /* implemented in software */
  47. #define _SUN4C_PAGE_IO           0x04000000   /* I/O page */
  48. #define _SUN4C_PAGE_READ         0x00800000   /* implemented in software */
  49. #define _SUN4C_PAGE_WRITE        0x00400000   /* implemented in software */
  50. #define _SUN4C_PAGE_ACCESSED     0x00200000   /* implemented in software */
  51. #define _SUN4C_PAGE_MODIFIED     0x00100000   /* implemented in software */
  52. #define _SUN4C_READABLE (_SUN4C_PAGE_READ|_SUN4C_PAGE_SILENT_READ|
  53.  _SUN4C_PAGE_ACCESSED)
  54. #define _SUN4C_WRITEABLE (_SUN4C_PAGE_WRITE|_SUN4C_PAGE_SILENT_WRITE|
  55.  _SUN4C_PAGE_MODIFIED)
  56. #define _SUN4C_PAGE_CHG_MASK (0xffff|_SUN4C_PAGE_ACCESSED|_SUN4C_PAGE_MODIFIED)
  57. #define SUN4C_PAGE_NONE __pgprot(_SUN4C_PAGE_PRESENT)
  58. #define SUN4C_PAGE_SHARED __pgprot(_SUN4C_PAGE_PRESENT|_SUN4C_READABLE|
  59.  _SUN4C_PAGE_WRITE)
  60. #define SUN4C_PAGE_COPY __pgprot(_SUN4C_PAGE_PRESENT|_SUN4C_READABLE)
  61. #define SUN4C_PAGE_READONLY __pgprot(_SUN4C_PAGE_PRESENT|_SUN4C_READABLE)
  62. #define SUN4C_PAGE_KERNEL __pgprot(_SUN4C_READABLE|_SUN4C_WRITEABLE|
  63.  _SUN4C_PAGE_DIRTY|_SUN4C_PAGE_PRIV)
  64. #ifndef __ASSEMBLY__
  65. extern __inline__ unsigned long sun4c_get_synchronous_error(void)
  66. {
  67. unsigned long sync_err;
  68. __asm__ __volatile__("lda [%1] %2, %0nt" :
  69.      "=r" (sync_err) :
  70.      "r" (AC_SYNC_ERR), "i" (ASI_CONTROL));
  71. return sync_err;
  72. }
  73. extern __inline__ unsigned long sun4c_get_synchronous_address(void)
  74. {
  75. unsigned long sync_addr;
  76. __asm__ __volatile__("lda [%1] %2, %0nt" :
  77.      "=r" (sync_addr) :
  78.      "r" (AC_SYNC_VA), "i" (ASI_CONTROL));
  79. return sync_addr;
  80. }
  81. /* SUN4C pte, segmap, and context manipulation */
  82. extern __inline__ unsigned long sun4c_get_segmap(unsigned long addr)
  83. {
  84.   register unsigned long entry;
  85.   __asm__ __volatile__("ntlduba [%1] %2, %0nt" : 
  86.        "=r" (entry) :
  87.        "r" (addr), "i" (ASI_SEGMAP));
  88.   return entry;
  89. }
  90. extern __inline__ void sun4c_put_segmap(unsigned long addr, unsigned long entry)
  91. {
  92.   __asm__ __volatile__("ntstba %1, [%0] %2; nop; nop; nop;nt" : :
  93.        "r" (addr), "r" (entry),
  94.        "i" (ASI_SEGMAP));
  95. }
  96. extern __inline__ unsigned long sun4c_get_pte(unsigned long addr)
  97. {
  98.   register unsigned long entry;
  99.   __asm__ __volatile__("ntlda [%1] %2, %0nt" : 
  100.        "=r" (entry) :
  101.        "r" (addr), "i" (ASI_PTE));
  102.   return entry;
  103. }
  104. extern __inline__ void sun4c_put_pte(unsigned long addr, unsigned long entry)
  105. {
  106.   __asm__ __volatile__("ntsta %1, [%0] %2; nop; nop; nop;nt" : :
  107.        "r" (addr), 
  108.        "r" ((entry & ~(_SUN4C_PAGE_PRESENT))), "i" (ASI_PTE));
  109. }
  110. extern __inline__ int sun4c_get_context(void)
  111. {
  112.   register int ctx;
  113.   __asm__ __volatile__("ntlduba [%1] %2, %0nt" :
  114.        "=r" (ctx) :
  115.        "r" (AC_CONTEXT), "i" (ASI_CONTROL));
  116.   return ctx;
  117. }
  118. extern __inline__ int sun4c_set_context(int ctx)
  119. {
  120.   __asm__ __volatile__("ntstba %0, [%1] %2; nop; nop; nop;nt" : :
  121.        "r" (ctx), "r" (AC_CONTEXT), "i" (ASI_CONTROL));
  122.   return ctx;
  123. }
  124. #endif /* !(__ASSEMBLY__) */
  125. #endif /* !(_SPARC_PGTSUN4C_H) */