diff options
author | Thiemo Seufer <ths@networkno.de> | 2005-04-25 12:36:23 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2005-10-29 14:31:11 -0400 |
commit | ba5187dbb4b2eac99d6fa1d6bbece67e0066bf51 (patch) | |
tree | 9a1fa0b0cb6ff1c64c20569c4e6ecdfd3f865bbc /arch/mips/mm/sc-rm7k.c | |
parent | 7de8d2328767cf4cb463dd3ca70c44985ac835a8 (diff) |
Better interface to run uncached cache setup code.
Signed-off-by: Thiemo Seufer <ths@networkno.de>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/mm/sc-rm7k.c')
-rw-r--r-- | arch/mips/mm/sc-rm7k.c | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/arch/mips/mm/sc-rm7k.c b/arch/mips/mm/sc-rm7k.c index 4e92f931aaba..1df5aab82c13 100644 --- a/arch/mips/mm/sc-rm7k.c +++ b/arch/mips/mm/sc-rm7k.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <asm/cacheops.h> | 15 | #include <asm/cacheops.h> |
16 | #include <asm/mipsregs.h> | 16 | #include <asm/mipsregs.h> |
17 | #include <asm/processor.h> | 17 | #include <asm/processor.h> |
18 | #include <asm/cacheflush.h> /* for run_uncached() */ | ||
18 | 19 | ||
19 | /* Primary cache parameters. */ | 20 | /* Primary cache parameters. */ |
20 | #define sc_lsize 32 | 21 | #define sc_lsize 32 |
@@ -96,25 +97,13 @@ static void rm7k_sc_inv(unsigned long addr, unsigned long size) | |||
96 | } | 97 | } |
97 | 98 | ||
98 | /* | 99 | /* |
99 | * This function is executed in the uncached segment CKSEG1. | 100 | * This function is executed in uncached address space. |
100 | * It must not touch the stack, because the stack pointer still points | ||
101 | * into CKSEG0. | ||
102 | * | ||
103 | * Three options: | ||
104 | * - Write it in assembly and guarantee that we don't use the stack. | ||
105 | * - Disable caching for CKSEG0 before calling it. | ||
106 | * - Pray that GCC doesn't randomly start using the stack. | ||
107 | * | ||
108 | * This being Linux, we obviously take the least sane of those options - | ||
109 | * following DaveM's lead in c-r4k.c | ||
110 | * | ||
111 | * It seems we get our kicks from relying on unguaranteed behaviour in GCC | ||
112 | */ | 101 | */ |
113 | static __init void __rm7k_sc_enable(void) | 102 | static __init void __rm7k_sc_enable(void) |
114 | { | 103 | { |
115 | int i; | 104 | int i; |
116 | 105 | ||
117 | set_c0_config(1 << 3); /* CONF_SE */ | 106 | set_c0_config(R7K_CONF_SE); |
118 | 107 | ||
119 | write_c0_taglo(0); | 108 | write_c0_taglo(0); |
120 | write_c0_taghi(0); | 109 | write_c0_taghi(0); |
@@ -127,24 +116,22 @@ static __init void __rm7k_sc_enable(void) | |||
127 | ".set mips0\n\t" | 116 | ".set mips0\n\t" |
128 | ".set reorder" | 117 | ".set reorder" |
129 | : | 118 | : |
130 | : "r" (KSEG0ADDR(i)), "i" (Index_Store_Tag_SD)); | 119 | : "r" (CKSEG0ADDR(i)), "i" (Index_Store_Tag_SD)); |
131 | } | 120 | } |
132 | } | 121 | } |
133 | 122 | ||
134 | static __init void rm7k_sc_enable(void) | 123 | static __init void rm7k_sc_enable(void) |
135 | { | 124 | { |
136 | void (*func)(void) = (void *) KSEG1ADDR(&__rm7k_sc_enable); | 125 | if (read_c0_config() & R7K_CONF_SE) |
137 | |||
138 | if (read_c0_config() & 0x08) /* CONF_SE */ | ||
139 | return; | 126 | return; |
140 | 127 | ||
141 | printk(KERN_INFO "Enabling secondary cache..."); | 128 | printk(KERN_INFO "Enabling secondary cache..."); |
142 | func(); | 129 | run_uncached(__rm7k_sc_enable); |
143 | } | 130 | } |
144 | 131 | ||
145 | static void rm7k_sc_disable(void) | 132 | static void rm7k_sc_disable(void) |
146 | { | 133 | { |
147 | clear_c0_config(1<<3); /* CONF_SE */ | 134 | clear_c0_config(R7K_CONF_SE); |
148 | } | 135 | } |
149 | 136 | ||
150 | struct bcache_ops rm7k_sc_ops = { | 137 | struct bcache_ops rm7k_sc_ops = { |
@@ -164,7 +151,7 @@ void __init rm7k_sc_init(void) | |||
164 | printk(KERN_INFO "Secondary cache size %dK, linesize %d bytes.\n", | 151 | printk(KERN_INFO "Secondary cache size %dK, linesize %d bytes.\n", |
165 | (scache_size >> 10), sc_lsize); | 152 | (scache_size >> 10), sc_lsize); |
166 | 153 | ||
167 | if (!((config >> 3) & 1)) /* CONF_SE */ | 154 | if (!(config & R7K_CONF_SE)) |
168 | rm7k_sc_enable(); | 155 | rm7k_sc_enable(); |
169 | 156 | ||
170 | /* | 157 | /* |