mmu.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #ifndef _ASM_CRIS_ARCH_MMU_H
  2. #define _ASM_CRIS_ARCH_MMU_H
  3. /* MMU context type. */
  4. typedef struct
  5. {
  6. unsigned int page_id;
  7. } mm_context_t;
  8. /* Kernel memory segments. */
  9. #define KSEG_F 0xf0000000UL
  10. #define KSEG_E 0xe0000000UL
  11. #define KSEG_D 0xd0000000UL
  12. #define KSEG_C 0xc0000000UL
  13. #define KSEG_B 0xb0000000UL
  14. #define KSEG_A 0xa0000000UL
  15. #define KSEG_9 0x90000000UL
  16. #define KSEG_8 0x80000000UL
  17. #define KSEG_7 0x70000000UL
  18. #define KSEG_6 0x60000000UL
  19. #define KSEG_5 0x50000000UL
  20. #define KSEG_4 0x40000000UL
  21. #define KSEG_3 0x30000000UL
  22. #define KSEG_2 0x20000000UL
  23. #define KSEG_1 0x10000000UL
  24. #define KSEG_0 0x00000000UL
  25. /*
  26. * CRISv32 PTE bits:
  27. *
  28. * Bit: 31-13 12-5 4 3 2 1 0
  29. * +-----+------+--------+-------+--------+-------+---------+
  30. * | pfn | zero | global | valid | kernel | write | execute |
  31. * +-----+------+--------+-------+--------+-------+---------+
  32. */
  33. /*
  34. * Defines for accessing the bits. Also define some synonyms for use with
  35. * the software-based defined bits below.
  36. */
  37. #define _PAGE_EXECUTE (1 << 0) /* Execution bit. */
  38. #define _PAGE_WE (1 << 1) /* Write bit. */
  39. #define _PAGE_SILENT_WRITE (1 << 1) /* Same as above. */
  40. #define _PAGE_KERNEL (1 << 2) /* Kernel mode page. */
  41. #define _PAGE_VALID (1 << 3) /* Page is valid. */
  42. #define _PAGE_SILENT_READ (1 << 3) /* Same as above. */
  43. #define _PAGE_GLOBAL (1 << 4) /* Global page. */
  44. /*
  45. * The hardware doesn't care about these bits, but the kernel uses them in
  46. * software.
  47. */
  48. #define _PAGE_PRESENT (1 << 5) /* Page is present in memory. */
  49. #define _PAGE_FILE (1 << 6) /* 1=pagecache, 0=swap (when !present) */
  50. #define _PAGE_ACCESSED (1 << 6) /* Simulated in software using valid bit. */
  51. #define _PAGE_MODIFIED (1 << 7) /* Simulated in software using we bit. */
  52. #define _PAGE_READ (1 << 8) /* Read enabled. */
  53. #define _PAGE_WRITE (1 << 9) /* Write enabled. */
  54. /* Define some higher level generic page attributes. */
  55. #define __READABLE (_PAGE_READ | _PAGE_SILENT_READ | _PAGE_ACCESSED)
  56. #define __WRITEABLE (_PAGE_WRITE | _PAGE_SILENT_WRITE | _PAGE_MODIFIED)
  57. #define _PAGE_TABLE (_PAGE_PRESENT | __READABLE | __WRITEABLE)
  58. #define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_MODIFIED)
  59. #define PAGE_NONE __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED)
  60. #define PAGE_SHARED __pgprot(_PAGE_PRESENT | __READABLE | _PAGE_WRITE | \
  61. _PAGE_ACCESSED)
  62. #define PAGE_SHARED_EXEC __pgprot(_PAGE_PRESENT | __READABLE | _PAGE_WRITE | \
  63. _PAGE_ACCESSED | _PAGE_EXECUTE)
  64. #define PAGE_READONLY __pgprot(_PAGE_PRESENT | __READABLE)
  65. #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | __READABLE | _PAGE_EXECUTE | _PAGE_ACCESSED)
  66. #define PAGE_COPY __pgprot(_PAGE_PRESENT | __READABLE)
  67. #define PAGE_COPY_EXEC __pgprot(_PAGE_PRESENT | __READABLE | _PAGE_EXECUTE)
  68. #define PAGE_KERNEL __pgprot(_PAGE_GLOBAL | _PAGE_KERNEL | \
  69. _PAGE_PRESENT | __READABLE | __WRITEABLE)
  70. #define PAGE_KERNEL_EXEC __pgprot(_PAGE_GLOBAL | _PAGE_KERNEL | _PAGE_EXECUTE | \
  71. _PAGE_PRESENT | __READABLE | __WRITEABLE)
  72. #define PAGE_SIGNAL_TRAMPOLINE __pgprot(_PAGE_GLOBAL | _PAGE_EXECUTE | \
  73. _PAGE_PRESENT | __READABLE)
  74. #define _KERNPG_TABLE (_PAGE_TABLE | _PAGE_KERNEL)
  75. /* CRISv32 can do page protection for execute.
  76. * Write permissions imply read permissions.
  77. * Note that the numbers are in Execute-Write-Read order!
  78. */
  79. #define __P000 PAGE_NONE
  80. #define __P001 PAGE_READONLY
  81. #define __P010 PAGE_COPY
  82. #define __P011 PAGE_COPY
  83. #define __P100 PAGE_READONLY_EXEC
  84. #define __P101 PAGE_READONLY_EXEC
  85. #define __P110 PAGE_COPY_EXEC
  86. #define __P111 PAGE_COPY_EXEC
  87. #define __S000 PAGE_NONE
  88. #define __S001 PAGE_READONLY
  89. #define __S010 PAGE_SHARED
  90. #define __S011 PAGE_SHARED
  91. #define __S100 PAGE_READONLY_EXEC
  92. #define __S101 PAGE_READONLY_EXEC
  93. #define __S110 PAGE_SHARED_EXEC
  94. #define __S111 PAGE_SHARED_EXEC
  95. #define PTE_FILE_MAX_BITS 25
  96. #endif /* _ASM_CRIS_ARCH_MMU_H */