cache.h 3.9 KB

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