mmu.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. # ifndef __ASSEMBLY__
  14. typedef struct {
  15. struct vm_list_struct *vmlist;
  16. unsigned long end_brk;
  17. } mm_context_t;
  18. # endif /* __ASSEMBLY__ */
  19. # else /* CONFIG_MMU */
  20. # ifdef __KERNEL__
  21. # ifndef __ASSEMBLY__
  22. /* Default "unsigned long" context */
  23. typedef unsigned long mm_context_t;
  24. /* Hardware Page Table Entry */
  25. typedef struct _PTE {
  26. unsigned long v:1; /* Entry is valid */
  27. unsigned long vsid:24; /* Virtual segment identifier */
  28. unsigned long h:1; /* Hash algorithm indicator */
  29. unsigned long api:6; /* Abbreviated page index */
  30. unsigned long rpn:20; /* Real (physical) page number */
  31. unsigned long :3; /* Unused */
  32. unsigned long r:1; /* Referenced */
  33. unsigned long c:1; /* Changed */
  34. unsigned long w:1; /* Write-thru cache mode */
  35. unsigned long i:1; /* Cache inhibited */
  36. unsigned long m:1; /* Memory coherence */
  37. unsigned long g:1; /* Guarded */
  38. unsigned long :1; /* Unused */
  39. unsigned long pp:2; /* Page protection */
  40. } PTE;
  41. /* Values for PP (assumes Ks=0, Kp=1) */
  42. # define PP_RWXX 0 /* Supervisor read/write, User none */
  43. # define PP_RWRX 1 /* Supervisor read/write, User read */
  44. # define PP_RWRW 2 /* Supervisor read/write, User read/write */
  45. # define PP_RXRX 3 /* Supervisor read, User read */
  46. /* Segment Register */
  47. typedef struct _SEGREG {
  48. unsigned long t:1; /* Normal or I/O type */
  49. unsigned long ks:1; /* Supervisor 'key' (normally 0) */
  50. unsigned long kp:1; /* User 'key' (normally 1) */
  51. unsigned long n:1; /* No-execute */
  52. unsigned long :4; /* Unused */
  53. unsigned long vsid:24; /* Virtual Segment Identifier */
  54. } SEGREG;
  55. extern void _tlbie(unsigned long va); /* invalidate a TLB entry */
  56. extern void _tlbia(void); /* invalidate all TLB entries */
  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. /*
  68. * TLB entries are defined by a "high" tag portion and a "low" data
  69. * portion. The data portion is 32-bits.
  70. *
  71. * TLB entries are managed entirely under software control by reading,
  72. * writing, and searching using the MTS and MFS instructions.
  73. */
  74. # define TLB_LO 1
  75. # define TLB_HI 0
  76. # define TLB_DATA TLB_LO
  77. # define TLB_TAG TLB_HI
  78. /* Tag portion */
  79. # define TLB_EPN_MASK 0xFFFFFC00 /* Effective Page Number */
  80. # define TLB_PAGESZ_MASK 0x00000380
  81. # define TLB_PAGESZ(x) (((x) & 0x7) << 7)
  82. # define PAGESZ_1K 0
  83. # define PAGESZ_4K 1
  84. # define PAGESZ_16K 2
  85. # define PAGESZ_64K 3
  86. # define PAGESZ_256K 4
  87. # define PAGESZ_1M 5
  88. # define PAGESZ_4M 6
  89. # define PAGESZ_16M 7
  90. # define TLB_VALID 0x00000040 /* Entry is valid */
  91. /* Data portion */
  92. # define TLB_RPN_MASK 0xFFFFFC00 /* Real Page Number */
  93. # define TLB_PERM_MASK 0x00000300
  94. # define TLB_EX 0x00000200 /* Instruction execution allowed */
  95. # define TLB_WR 0x00000100 /* Writes permitted */
  96. # define TLB_ZSEL_MASK 0x000000F0
  97. # define TLB_ZSEL(x) (((x) & 0xF) << 4)
  98. # define TLB_ATTR_MASK 0x0000000F
  99. # define TLB_W 0x00000008 /* Caching is write-through */
  100. # define TLB_I 0x00000004 /* Caching is inhibited */
  101. # define TLB_M 0x00000002 /* Memory is coherent */
  102. # define TLB_G 0x00000001 /* Memory is guarded from prefetch */
  103. # endif /* __KERNEL__ */
  104. # endif /* CONFIG_MMU */
  105. #endif /* _ASM_MICROBLAZE_MMU_H */