mmu.h 4.0 KB

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