cache.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. #ifndef __ASM_SH64_CACHE_H
  2. #define __ASM_SH64_CACHE_H
  3. /*
  4. * This file is subject to the terms and conditions of the GNU General Public
  5. * License. See the file "COPYING" in the main directory of this archive
  6. * for more details.
  7. *
  8. * include/asm-sh64/cache.h
  9. *
  10. * Copyright (C) 2000, 2001 Paolo Alberelli
  11. * Copyright (C) 2003, 2004 Paul Mundt
  12. *
  13. */
  14. #include <asm/cacheflush.h>
  15. #define L1_CACHE_SHIFT 5
  16. /* bytes per L1 cache line */
  17. #define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
  18. #define L1_CACHE_ALIGN_MASK (~(L1_CACHE_BYTES - 1))
  19. #define L1_CACHE_ALIGN(x) (((x)+(L1_CACHE_BYTES - 1)) & L1_CACHE_ALIGN_MASK)
  20. #define L1_CACHE_SIZE_BYTES (L1_CACHE_BYTES << 10)
  21. /* Largest L1 which this arch supports */
  22. #define L1_CACHE_SHIFT_MAX 5
  23. #ifdef MODULE
  24. #define __cacheline_aligned __attribute__((__aligned__(L1_CACHE_BYTES)))
  25. #else
  26. #define __cacheline_aligned \
  27. __attribute__((__aligned__(L1_CACHE_BYTES), \
  28. __section__(".data.cacheline_aligned")))
  29. #endif
  30. /*
  31. * Control Registers.
  32. */
  33. #define ICCR_BASE 0x01600000 /* Instruction Cache Control Register */
  34. #define ICCR_REG0 0 /* Register 0 offset */
  35. #define ICCR_REG1 1 /* Register 1 offset */
  36. #define ICCR0 ICCR_BASE+ICCR_REG0
  37. #define ICCR1 ICCR_BASE+ICCR_REG1
  38. #define ICCR0_OFF 0x0 /* Set ICACHE off */
  39. #define ICCR0_ON 0x1 /* Set ICACHE on */
  40. #define ICCR0_ICI 0x2 /* Invalidate all in IC */
  41. #define ICCR1_NOLOCK 0x0 /* Set No Locking */
  42. #define OCCR_BASE 0x01E00000 /* Operand Cache Control Register */
  43. #define OCCR_REG0 0 /* Register 0 offset */
  44. #define OCCR_REG1 1 /* Register 1 offset */
  45. #define OCCR0 OCCR_BASE+OCCR_REG0
  46. #define OCCR1 OCCR_BASE+OCCR_REG1
  47. #define OCCR0_OFF 0x0 /* Set OCACHE off */
  48. #define OCCR0_ON 0x1 /* Set OCACHE on */
  49. #define OCCR0_OCI 0x2 /* Invalidate all in OC */
  50. #define OCCR0_WT 0x4 /* Set OCACHE in WT Mode */
  51. #define OCCR0_WB 0x0 /* Set OCACHE in WB Mode */
  52. #define OCCR1_NOLOCK 0x0 /* Set No Locking */
  53. /*
  54. * SH-5
  55. * A bit of description here, for neff=32.
  56. *
  57. * |<--- tag (19 bits) --->|
  58. * +-----------------------------+-----------------+------+----------+------+
  59. * | | | ways |set index |offset|
  60. * +-----------------------------+-----------------+------+----------+------+
  61. * ^ 2 bits 8 bits 5 bits
  62. * +- Bit 31
  63. *
  64. * Cacheline size is based on offset: 5 bits = 32 bytes per line
  65. * A cache line is identified by a tag + set but OCACHETAG/ICACHETAG
  66. * have a broader space for registers. These are outlined by
  67. * CACHE_?C_*_STEP below.
  68. *
  69. */
  70. /* Valid and Dirty bits */
  71. #define SH_CACHE_VALID (1LL<<0)
  72. #define SH_CACHE_UPDATED (1LL<<57)
  73. /* Cache flags */
  74. #define SH_CACHE_MODE_WT (1LL<<0)
  75. #define SH_CACHE_MODE_WB (1LL<<1)
  76. #ifndef __ASSEMBLY__
  77. /*
  78. * Cache information structure.
  79. *
  80. * Defined for both I and D cache, per-processor.
  81. */
  82. struct cache_info {
  83. unsigned int ways;
  84. unsigned int sets;
  85. unsigned int linesz;
  86. unsigned int way_shift;
  87. unsigned int entry_shift;
  88. unsigned int set_shift;
  89. unsigned int way_step_shift;
  90. unsigned int asid_shift;
  91. unsigned int way_ofs;
  92. unsigned int asid_mask;
  93. unsigned int idx_mask;
  94. unsigned int epn_mask;
  95. unsigned long flags;
  96. };
  97. #endif /* __ASSEMBLY__ */
  98. /* Instruction cache */
  99. #define CACHE_IC_ADDRESS_ARRAY 0x01000000
  100. /* Operand Cache */
  101. #define CACHE_OC_ADDRESS_ARRAY 0x01800000
  102. /* These declarations relate to cache 'synonyms' in the operand cache. A
  103. 'synonym' occurs where effective address bits overlap between those used for
  104. indexing the cache sets and those passed to the MMU for translation. In the
  105. case of SH5-101 & SH5-103, only bit 12 is affected for 4k pages. */
  106. #define CACHE_OC_N_SYNBITS 1 /* Number of synonym bits */
  107. #define CACHE_OC_SYN_SHIFT 12
  108. /* Mask to select synonym bit(s) */
  109. #define CACHE_OC_SYN_MASK (((1UL<<CACHE_OC_N_SYNBITS)-1)<<CACHE_OC_SYN_SHIFT)
  110. /*
  111. * Instruction cache can't be invalidated based on physical addresses.
  112. * No Instruction Cache defines required, then.
  113. */
  114. #endif /* __ASM_SH64_CACHE_H */