• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision4a618c7ab787769ddd71200e0ae8bf538df35bae (tree)
Zeit2016-05-22 15:07:43
AutorYoshinori Sato <ysato@user...>
CommiterYoshinori Sato

Log Message

sh: Update cache control.

D-Cache control support.

Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>

Ändern Zusammenfassung

Diff

--- a/arch/sh/cpu/sh4/cache.c
+++ b/arch/sh/cpu/sh4/cache.c
@@ -68,11 +68,12 @@ static inline void cache_wback_all(void)
6868 back_to_P1();
6969 }
7070
71+static unsigned long ccr_bit[] = {
72+ 0x00000900, /* ICE */
73+ 0x0000000b, /* OCE,WT */
74+};
7175
72-#define CACHE_ENABLE 0
73-#define CACHE_DISABLE 1
74-
75-int cache_control(unsigned int cmd)
76+int cache_control(unsigned int io, unsigned int cmd)
7677 {
7778 unsigned long ccr;
7879
@@ -82,23 +83,38 @@ int cache_control(unsigned int cmd)
8283 if (ccr & CCR_CACHE_ENABLE)
8384 cache_wback_all();
8485
85- if (cmd == CACHE_DISABLE)
86- outl(CCR_CACHE_STOP, CCR);
86+#ifdef CONFIG_CPU_TYPE_R
87+ if (!ccr)
88+ ccr |= 0x80000000;
89+#endif
90+ if (cmd == ON)
91+ ccr |= ccr_bit[io];
8792 else
88- outl(CCR_CACHE_INIT, CCR);
93+ ccr &= ~ccr_bit[io];
94+ outl(ccr, CCR);
95+
8996 back_to_P1();
9097
9198 return 0;
9299 }
93100
101+int cache_status(unsigned int io)
102+{
103+ unsigned long ccr;
104+
105+ ccr = inl(CCR);
106+ return ccr & ccr_bit[io];
107+}
108+
94109 void flush_dcache_range(unsigned long start, unsigned long end)
95110 {
96111 u32 v;
97112
113+ printf("%s\n", __func__);
98114 start &= ~(L1_CACHE_BYTES - 1);
99115 for (v = start; v < end; v += L1_CACHE_BYTES) {
100116 asm volatile ("ocbwb %0" : /* no output */
101- : "m" (__m(v)));
117+ : "m" (*(unsigned long *)v));
102118 }
103119 }
104120
@@ -109,6 +125,6 @@ void invalidate_dcache_range(unsigned long start, unsigned long end)
109125 start &= ~(L1_CACHE_BYTES - 1);
110126 for (v = start; v < end; v += L1_CACHE_BYTES) {
111127 asm volatile ("ocbi %0" : /* no output */
112- : "m" (__m(v)));
128+ : "m" (*(unsigned long *)v));
113129 }
114130 }
--- a/arch/sh/cpu/sh4/cpu.c
+++ b/arch/sh/cpu/sh4/cpu.c
@@ -46,30 +46,32 @@ void flush_cache (unsigned long addr, unsigned long size)
4646
4747 void icache_enable (void)
4848 {
49- cache_control(0);
49+ cache_control(ICACHE, ON);
5050 }
5151
5252 void icache_disable (void)
5353 {
54- cache_control(1);
54+ cache_control(ICACHE, OFF);
5555 }
5656
5757 int icache_status (void)
5858 {
59- return 0;
59+ return cache_status(ICACHE);
6060 }
6161
6262 void dcache_enable (void)
6363 {
64+ cache_control(OCACHE, ON);
6465 }
6566
6667 void dcache_disable (void)
6768 {
69+ cache_control(OCACHE, OFF);
6870 }
6971
7072 int dcache_status (void)
7173 {
72- return 0;
74+ return cache_status(OCACHE);
7375 }
7476
7577 int cpu_eth_init(bd_t *bis)
--- a/arch/sh/include/asm/cache.h
+++ b/arch/sh/include/asm/cache.h
@@ -3,10 +3,16 @@
33
44 #if defined(CONFIG_CPU_SH4)
55
6-int cache_control(unsigned int cmd);
6+int cache_control(unsigned int io, unsigned int cmd);
7+int cache_status(unsigned int io);
78
89 #define L1_CACHE_BYTES 32
910
11+#define ICACHE 0
12+#define OCACHE 1
13+#define ON 0
14+#define OFF 1
15+
1016 struct __large_struct { unsigned long buf[100]; };
1117 #define __m(x) (*(struct __large_struct *)(x))
1218