mmu.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * Copyright (C) 2008-2009 Michal Simek <monstr@monstr.eu>
  3. * Copyright (C) 2008-2009 PetaLogix
  4. * Copyright (C) 2006 Atmark Techno, Inc.
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #ifndef _ASM_MICROBLAZE_MMU_H
  11. #define _ASM_MICROBLAZE_MMU_H
  12. # ifndef CONFIG_MMU
  13. # include <asm-generic/mmu.h>
  14. # else /* CONFIG_MMU */
  15. # ifdef __KERNEL__
  16. # ifndef __ASSEMBLY__
  17. /* Default "unsigned long" context */
  18. typedef unsigned long mm_context_t;
  19. /* Hardware Page Table Entry */
  20. typedef struct _PTE {
  21. unsigned long v:1; /* Entry is valid */
  22. unsigned long vsid:24; /* Virtual segment identifier */
  23. unsigned long h:1; /* Hash algorithm indicator */
  24. unsigned long api:6; /* Abbreviated page index */
  25. unsigned long rpn:20; /* Real (physical) page number */
  26. unsigned long :3; /* Unused */
  27. unsigned long r:1; /* Referenced */
  28. unsigned long c:1; /* Changed */
  29. unsigned long w:1; /* Write-thru cache mode */
  30. unsigned long i:1; /* Cache inhibited */
  31. unsigned long m:1; /* Memory coherence */
  32. unsigned long g:1; /* Guarded */
  33. unsigned long :1; /* Unused */
  34. unsigned long pp:2; /* Page protection */
  35. } PTE;
  36. /* Values for PP (assumes Ks=0, Kp=1) */
  37. # define PP_RWXX 0 /* Supervisor read/write, User none */
  38. # define PP_RWRX 1 /* Supervisor read/write, User read */
  39. # define PP_RWRW 2 /* Supervisor read/write, User read/write */
  40. # define PP_RXRX 3 /* Supervisor read, User read */
  41. /* Segment Register */
  42. typedef struct _SEGREG {
  43. unsigned long t:1; /* Normal or I/O type */
  44. unsigned long ks:1; /* Supervisor 'key' (normally 0) */
  45. unsigned long kp:1; /* User 'key' (normally 1) */
  46. unsigned long n:1; /* No-execute */
  47. unsigned long :4; /* Unused */
  48. unsigned long vsid:24; /* Virtual Segment Identifier */
  49. } SEGREG;
  50. extern void _tlbie(unsigned long va); /* invalidate a TLB entry */
  51. extern void _tlbia(void); /* invalidate all TLB entries */
  52. /*
  53. * tlb_skip size stores actual number skipped TLBs from TLB0 - every directy TLB
  54. * mapping has to increase tlb_skip size.
  55. */
  56. extern u32 tlb_skip;
  57. # endif /* __ASSEMBLY__ */
  58. /*
  59. * The MicroBlaze processor has a TLB architecture identical to PPC-40x. The
  60. * instruction and data sides share a unified, 64-entry, semi-associative
  61. * TLB which is maintained totally under software control. In addition, the
  62. * instruction side has a hardware-managed, 2,4, or 8-entry, fully-associative
  63. * TLB which serves as a first level to the shared TLB. These two TLBs are
  64. * known as the UTLB and ITLB, respectively.
  65. */
  66. # define MICROBLAZE_TLB_SIZE 64
  67. /* For cases when you want to skip some TLB entries */
  68. # define MICROBLAZE_TLB_SKIP 0
  69. /* Use the last TLB for temporary access to LMB */
  70. # define MICROBLAZE_LMB_TLB_ID 63
  71. /*
  72. * TLB entries are defined by a "high" tag portion and a "low" data
  73. * portion. The data portion is 32-bits.
  74. *
  75. * TLB entries are managed entirely under software control by reading,
  76. * writing, and searching using the MTS and MFS instructions.
  77. */
  78. # define TLB_LO 1
  79. # define TLB_HI 0
  80. # define TLB_DATA TLB_LO
  81. # define TLB_TAG TLB_HI
  82. /* Tag portion */
  83. # define TLB_EPN_MASK 0xFFFFFC00 /* Effective Page Number */
  84. # define TLB_PAGESZ_MASK 0x00000380
  85. # define TLB_PAGESZ(x) (((x) & 0x7) << 7)
  86. # define PAGESZ_1K 0
  87. # define PAGESZ_4K 1
  88. # define PAGESZ_16K 2
  89. # define PAGESZ_64K 3
  90. # define PAGESZ_256K 4
  91. # define PAGESZ_1M 5
  92. # define PAGESZ_4M 6
  93. # define PAGESZ_16M 7
  94. # define TLB_VALID 0x00000040 /* Entry is valid */
  95. /* Data portion */
  96. # define TLB_RPN_MASK 0xFFFFFC00 /* Real Page Number */
  97. # define TLB_PERM_MASK 0x00000300
  98. # define TLB_EX 0x00000200 /* Instruction execution allowed */
  99. # define TLB_WR 0x00000100 /* Writes permitted */
  100. # define TLB_ZSEL_MASK 0x000000F0
  101. # define TLB_ZSEL(x) (((x) & 0xF) << 4)
  102. # define TLB_ATTR_MASK 0x0000000F
  103. # define TLB_W 0x00000008 /* Caching is write-through */
  104. # define TLB_I 0x00000004 /* Caching is inhibited */
  105. # define TLB_M 0x00000002 /* Memory is coherent */
  106. # define TLB_G 0x00000001 /* Memory is guarded from prefetch */
  107. # endif /* __KERNEL__ */
  108. # endif /* CONFIG_MMU */
  109. #endif /* _ASM_MICROBLAZE_MMU_H */