mmu.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * CRIS MMU constants and PTE layout
  3. */
  4. #ifndef _CRIS_ARCH_MMU_H
  5. #define _CRIS_ARCH_MMU_H
  6. /* type used in struct mm to couple an MMU context to an active mm */
  7. typedef struct
  8. {
  9. unsigned int page_id;
  10. } mm_context_t;
  11. /* kernel memory segments */
  12. #define KSEG_F 0xf0000000UL
  13. #define KSEG_E 0xe0000000UL
  14. #define KSEG_D 0xd0000000UL
  15. #define KSEG_C 0xc0000000UL
  16. #define KSEG_B 0xb0000000UL
  17. #define KSEG_A 0xa0000000UL
  18. #define KSEG_9 0x90000000UL
  19. #define KSEG_8 0x80000000UL
  20. #define KSEG_7 0x70000000UL
  21. #define KSEG_6 0x60000000UL
  22. #define KSEG_5 0x50000000UL
  23. #define KSEG_4 0x40000000UL
  24. #define KSEG_3 0x30000000UL
  25. #define KSEG_2 0x20000000UL
  26. #define KSEG_1 0x10000000UL
  27. #define KSEG_0 0x00000000UL
  28. /* CRIS PTE bits (see R_TLB_LO in the register description)
  29. *
  30. * Bit: 31-13 12-------4 3 2 1 0
  31. * ________________________________________________
  32. * | pfn | reserved | global | valid | kernel | we |
  33. * |_____|__________|________|_______|________|_____|
  34. *
  35. * (pfn = physical frame number)
  36. */
  37. /* Real HW-based PTE bits. We use some synonym names so that
  38. * things become less confusing in combination with the SW-based
  39. * bits further below.
  40. *
  41. */
  42. #define _PAGE_WE (1<<0) /* page is write-enabled */
  43. #define _PAGE_SILENT_WRITE (1<<0) /* synonym */
  44. #define _PAGE_KERNEL (1<<1) /* page is kernel only */
  45. #define _PAGE_VALID (1<<2) /* page is valid */
  46. #define _PAGE_SILENT_READ (1<<2) /* synonym */
  47. #define _PAGE_GLOBAL (1<<3) /* global page - context is ignored */
  48. /* Bits the HW doesn't care about but the kernel uses them in SW */
  49. #define _PAGE_PRESENT (1<<4) /* page present in memory */
  50. #define _PAGE_FILE (1<<5) /* set: pagecache, unset: swap (when !PRESENT) */
  51. #define _PAGE_ACCESSED (1<<5) /* simulated in software using valid bit */
  52. #define _PAGE_MODIFIED (1<<6) /* simulated in software using we bit */
  53. #define _PAGE_READ (1<<7) /* read-enabled */
  54. #define _PAGE_WRITE (1<<8) /* write-enabled */
  55. /* Define some higher level generic page attributes. */
  56. #define __READABLE (_PAGE_READ | _PAGE_SILENT_READ | _PAGE_ACCESSED)
  57. #define __WRITEABLE (_PAGE_WRITE | _PAGE_SILENT_WRITE | _PAGE_MODIFIED)
  58. #define _PAGE_TABLE (_PAGE_PRESENT | __READABLE | __WRITEABLE)
  59. #define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_MODIFIED)
  60. #define PAGE_NONE __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED)
  61. #define PAGE_SHARED __pgprot(_PAGE_PRESENT | __READABLE | _PAGE_WRITE | \
  62. _PAGE_ACCESSED)
  63. #define PAGE_COPY __pgprot(_PAGE_PRESENT | __READABLE) // | _PAGE_COW
  64. #define PAGE_READONLY __pgprot(_PAGE_PRESENT | __READABLE)
  65. #define PAGE_KERNEL __pgprot(_PAGE_GLOBAL | _PAGE_KERNEL | \
  66. _PAGE_PRESENT | __READABLE | __WRITEABLE)
  67. #define _KERNPG_TABLE (_PAGE_TABLE | _PAGE_KERNEL)
  68. /*
  69. * CRIS can't do page protection for execute, and considers read the same.
  70. * Also, write permissions imply read permissions. This is the closest we can
  71. * get..
  72. */
  73. #define __P000 PAGE_NONE
  74. #define __P001 PAGE_READONLY
  75. #define __P010 PAGE_COPY
  76. #define __P011 PAGE_COPY
  77. #define __P100 PAGE_READONLY
  78. #define __P101 PAGE_READONLY
  79. #define __P110 PAGE_COPY
  80. #define __P111 PAGE_COPY
  81. #define __S000 PAGE_NONE
  82. #define __S001 PAGE_READONLY
  83. #define __S010 PAGE_SHARED
  84. #define __S011 PAGE_SHARED
  85. #define __S100 PAGE_READONLY
  86. #define __S101 PAGE_READONLY
  87. #define __S110 PAGE_SHARED
  88. #define __S111 PAGE_SHARED
  89. #define PTE_FILE_MAX_BITS 26
  90. #endif