summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2009-02-11 12:55:51 +0000
committerMichael Sevakis <jethead71@rockbox.org>2009-02-11 12:55:51 +0000
commit21f0c9a2829415f52b64cbdf965b01525e78f17a (patch)
treeb5cb8021097722969f75784011c9f64f991c0c3d /firmware
parent4cd7597172d916db9fc99bde4c03b669366f852a (diff)
downloadrockbox-21f0c9a2829415f52b64cbdf965b01525e78f17a.tar.gz
rockbox-21f0c9a2829415f52b64cbdf965b01525e78f17a.zip
Make basic cache functions into calls, and get rid of CACHE_FUNCTION_WRAPPERS and CACHE_FUNCTIONS_AS_CALL macros. Rename flush/invalidate_icache to cpucache_flush/invalidate. They're inlined only if an implementation isn't provided by defining HAVE_CPUCACHE_FLUSH/INVALIDATE.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19971 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/export/system.h16
-rw-r--r--firmware/rolo.c6
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/system-target.h32
-rw-r--r--firmware/target/arm/mmu-arm.c30
-rw-r--r--firmware/target/arm/s3c2440/gigabeat-fx/system-target.h14
-rw-r--r--firmware/target/arm/system-pp5002.c6
-rw-r--r--firmware/target/arm/system-pp502x.c6
-rw-r--r--firmware/target/arm/system-target.h9
-rw-r--r--firmware/target/coldfire/system-coldfire.c8
-rw-r--r--firmware/target/coldfire/system-target.h9
-rw-r--r--firmware/target/sh/system-target.h2
-rw-r--r--firmware/thread.c60
-rw-r--r--firmware/usbstack/usb_storage.c2
13 files changed, 100 insertions, 100 deletions
diff --git a/firmware/export/system.h b/firmware/export/system.h
index fb9dfa3003..b44600d2c2 100644
--- a/firmware/export/system.h
+++ b/firmware/export/system.h
@@ -272,12 +272,20 @@ static inline uint32_t swap_odd_even32(uint32_t value)
272#endif 272#endif
273 273
274/* Just define these as empty if not declared */ 274/* Just define these as empty if not declared */
275#ifndef HAVE_INVALIDATE_ICACHE 275#ifdef HAVE_CPUCACHE_INVALIDATE
276#define invalidate_icache() 276void cpucache_invalidate(void);
277#else
278static inline void cpucache_invalidate(void)
279{
280}
277#endif 281#endif
278 282
279#ifndef HAVE_FLUSH_ICACHE 283#ifdef HAVE_CPUCACHE_FLUSH
280#define flush_icache() 284void cpucache_flush(void);
285#else
286static inline void cpucache_flush(void)
287{
288}
281#endif 289#endif
282 290
283#ifdef PROC_NEEDS_CACHEALIGN 291#ifdef PROC_NEEDS_CACHEALIGN
diff --git a/firmware/rolo.c b/firmware/rolo.c
index 6a3fcd2bbb..014f00e2c7 100644
--- a/firmware/rolo.c
+++ b/firmware/rolo.c
@@ -75,7 +75,7 @@ void rolo_restart_cop(void)
75 COP_INT_DIS = -1; 75 COP_INT_DIS = -1;
76 76
77 /* Invalidate cache */ 77 /* Invalidate cache */
78 invalidate_icache(); 78 cpucache_invalidate();
79 79
80 /* Disable cache */ 80 /* Disable cache */
81 CACHE_CTL = CACHE_CTL_DISABLE; 81 CACHE_CTL = CACHE_CTL_DISABLE;
@@ -147,7 +147,7 @@ void rolo_restart(const unsigned char* source, unsigned char* dest,
147 CPU_INT_DIS = -1; 147 CPU_INT_DIS = -1;
148 148
149 /* Flush cache */ 149 /* Flush cache */
150 flush_icache(); 150 cpucache_flush();
151 151
152 /* Disable cache */ 152 /* Disable cache */
153 CACHE_CTL = CACHE_CTL_DISABLE; 153 CACHE_CTL = CACHE_CTL_DISABLE;
@@ -174,7 +174,7 @@ void rolo_restart(const unsigned char* source, unsigned char* dest,
174 174
175#elif defined(CPU_TCC780X) || (CONFIG_CPU == S3C2440) 175#elif defined(CPU_TCC780X) || (CONFIG_CPU == S3C2440)
176 /* Flush and invalidate caches */ 176 /* Flush and invalidate caches */
177 invalidate_icache(); 177 cpucache_invalidate();
178 178
179 asm volatile( 179 asm volatile(
180 "mov pc, %0 \n" 180 "mov pc, %0 \n"
diff --git a/firmware/target/arm/imx31/gigabeat-s/system-target.h b/firmware/target/arm/imx31/gigabeat-s/system-target.h
index ae50ec4c78..921af0ec8b 100644
--- a/firmware/target/arm/imx31/gigabeat-s/system-target.h
+++ b/firmware/target/arm/imx31/gigabeat-s/system-target.h
@@ -57,34 +57,12 @@ void imx31_regclr32(volatile uint32_t *reg_p, uint32_t mask);
57 57
58#define KDEV_INIT 58#define KDEV_INIT
59 59
60#define HAVE_INVALIDATE_ICACHE 60#define HAVE_CPUCACHE_INVALIDATE
61static inline void invalidate_icache(void) 61#define HAVE_CPUCACHE_FLUSH
62{
63 asm volatile(
64 /* Clean and invalidate entire data cache */
65 "mcr p15, 0, %0, c7, c14, 0 \n"
66 /* Invalidate entire instruction cache
67 * Also flushes the branch target cache */
68 "mcr p15, 0, %0, c7, c5, 0 \n"
69 /* Data synchronization barrier */
70 "mcr p15, 0, %0, c7, c10, 4 \n"
71 /* Flush prefetch buffer */
72 "mcr p15, 0, %0, c7, c5, 4 \n"
73 : : "r"(0)
74 );
75}
76 62
77#define HAVE_FLUSH_ICACHE 63/* Different internal names */
78static inline void flush_icache(void) 64#define cpucache_flush clean_dcache
79{ 65#define cpucache_invalidate invalidate_idcache
80 asm volatile (
81 /* Clean entire data cache */
82 "mcr p15, 0, %0, c7, c10, 0 \n"
83 /* Data synchronization barrier */
84 "mcr p15, 0, %0, c7, c10, 4 \n"
85 : : "r"(0)
86 );
87}
88 66
89struct ARM_REGS { 67struct ARM_REGS {
90 int r0; 68 int r0;
diff --git a/firmware/target/arm/mmu-arm.c b/firmware/target/arm/mmu-arm.c
index d86cd430b5..fae7fd0b8f 100644
--- a/firmware/target/arm/mmu-arm.c
+++ b/firmware/target/arm/mmu-arm.c
@@ -265,6 +265,8 @@ void __attribute__((naked)) clean_dcache(void)
265 /* Clean entire data cache */ 265 /* Clean entire data cache */
266 "mov r0, #0 \n" 266 "mov r0, #0 \n"
267 "mcr p15, 0, r0, c7, c10, 0 \n" 267 "mcr p15, 0, r0, c7, c10, 0 \n"
268 /* Data synchronization barrier */
269 "mcr p15, 0, r0, c7, c10, 4 \n"
268 "bx lr \n" 270 "bx lr \n"
269 ); 271 );
270} 272}
@@ -290,3 +292,31 @@ void clean_dcache(void)
290} 292}
291#endif 293#endif
292 294
295#if CONFIG_CPU == IMX31L
296void invalidate_idcache(void)
297{
298 asm volatile(
299 /* Clean and invalidate entire data cache */
300 "mcr p15, 0, %0, c7, c14, 0 \n"
301 /* Invalidate entire instruction cache
302 * Also flushes the branch target cache */
303 "mcr p15, 0, %0, c7, c5, 0 \n"
304 /* Data synchronization barrier */
305 "mcr p15, 0, %0, c7, c10, 4 \n"
306 /* Flush prefetch buffer */
307 "mcr p15, 0, %0, c7, c5, 4 \n"
308 : : "r"(0)
309 );
310}
311#else
312void invalidate_idcache(void)
313{
314 clean_dcache();
315 asm volatile(
316 "mov r0, #0 \n"
317 "mcr p15, 0, r0, c7, c5, 0 \n"
318 : : : "r0"
319 );
320}
321#endif
322
diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/system-target.h b/firmware/target/arm/s3c2440/gigabeat-fx/system-target.h
index 320c595b99..aa7c0aa50c 100644
--- a/firmware/target/arm/s3c2440/gigabeat-fx/system-target.h
+++ b/firmware/target/arm/s3c2440/gigabeat-fx/system-target.h
@@ -41,15 +41,9 @@ void s3c_regset32(volatile unsigned long *reg, unsigned long bits);
41/* Clear register bits */ 41/* Clear register bits */
42void s3c_regclr32(volatile unsigned long *reg, unsigned long bits); 42void s3c_regclr32(volatile unsigned long *reg, unsigned long bits);
43 43
44#define HAVE_INVALIDATE_ICACHE 44#define HAVE_CPUCACHE_FLUSH
45static inline void invalidate_icache(void) 45#define HAVE_CPUCACHE_INVALIDATE
46{ 46#define cpucache_flush clean_dcache
47 clean_dcache(); 47#define cpucache_invalidate invalidate_idcache
48 asm volatile(
49 "mov r0, #0 \n"
50 "mcr p15, 0, r0, c7, c5, 0 \n"
51 : : : "r0"
52 );
53}
54 48
55#endif /* SYSTEM_TARGET_H */ 49#endif /* SYSTEM_TARGET_H */
diff --git a/firmware/target/arm/system-pp5002.c b/firmware/target/arm/system-pp5002.c
index a995a5464b..98bf5f21f1 100644
--- a/firmware/target/arm/system-pp5002.c
+++ b/firmware/target/arm/system-pp5002.c
@@ -62,8 +62,7 @@ void __attribute__((interrupt("IRQ"))) irq_handler(void)
62 some other CPU frequency scaling. */ 62 some other CPU frequency scaling. */
63 63
64#ifndef BOOTLOADER 64#ifndef BOOTLOADER
65void flush_icache(void) ICODE_ATTR; 65void ICODE_ATTR cpucache_flush(void)
66void flush_icache(void)
67{ 66{
68 intptr_t b, e; 67 intptr_t b, e;
69 68
@@ -73,8 +72,7 @@ void flush_icache(void)
73 } 72 }
74} 73}
75 74
76void invalidate_icache(void) ICODE_ATTR; 75void ICODE_ATTR cpucache_invalidate(void)
77void invalidate_icache(void)
78{ 76{
79 intptr_t b, e; 77 intptr_t b, e;
80 78
diff --git a/firmware/target/arm/system-pp502x.c b/firmware/target/arm/system-pp502x.c
index b1cef7152a..10a7651f7b 100644
--- a/firmware/target/arm/system-pp502x.c
+++ b/firmware/target/arm/system-pp502x.c
@@ -163,8 +163,7 @@ void __attribute__((interrupt("IRQ"))) irq_handler(void)
163 to extend the funtions to do alternate cache configurations. */ 163 to extend the funtions to do alternate cache configurations. */
164 164
165#ifndef BOOTLOADER 165#ifndef BOOTLOADER
166void flush_icache(void) ICODE_ATTR; 166void ICODE_ATTR cpucache_flush(void)
167void flush_icache(void)
168{ 167{
169 if (CACHE_CTL & CACHE_CTL_ENABLE) 168 if (CACHE_CTL & CACHE_CTL_ENABLE)
170 { 169 {
@@ -173,8 +172,7 @@ void flush_icache(void)
173 } 172 }
174} 173}
175 174
176void invalidate_icache(void) ICODE_ATTR; 175void ICODE_ATTR cpucache_invalidate(void)
177void invalidate_icache(void)
178{ 176{
179 if (CACHE_CTL & CACHE_CTL_ENABLE) 177 if (CACHE_CTL & CACHE_CTL_ENABLE)
180 { 178 {
diff --git a/firmware/target/arm/system-target.h b/firmware/target/arm/system-target.h
index 4719b8c971..60844e0b5f 100644
--- a/firmware/target/arm/system-target.h
+++ b/firmware/target/arm/system-target.h
@@ -168,13 +168,8 @@ static inline void wake_core(int core)
168 168
169/** cache functions **/ 169/** cache functions **/
170#ifndef BOOTLOADER 170#ifndef BOOTLOADER
171#define CACHE_FUNCTIONS_AS_CALL 171#define HAVE_CPUCACHE_INVALIDATE
172 172#define HAVE_CPUCACHE_FLUSH
173#define HAVE_INVALIDATE_ICACHE
174void invalidate_icache(void);
175
176#define HAVE_FLUSH_ICACHE
177void flush_icache(void);
178#endif 173#endif
179 174
180#endif /* CPU_PP */ 175#endif /* CPU_PP */
diff --git a/firmware/target/coldfire/system-coldfire.c b/firmware/target/coldfire/system-coldfire.c
index c4651a3c80..a96cd34441 100644
--- a/firmware/target/coldfire/system-coldfire.c
+++ b/firmware/target/coldfire/system-coldfire.c
@@ -358,3 +358,11 @@ void coldfire_set_dataincontrol(unsigned long value)
358 DATAINCONTROL = (DATAINCONTROL & (1 << 9)) | value; 358 DATAINCONTROL = (DATAINCONTROL & (1 << 9)) | value;
359 restore_irq(level); 359 restore_irq(level);
360} 360}
361
362void cpucache_invalidate(void)
363{
364 asm volatile ("move.l #0x01000000,%d0\n"
365 "movec.l %d0,%cacr\n"
366 "move.l #0x80000000,%d0\n"
367 "movec.l %d0,%cacr");
368}
diff --git a/firmware/target/coldfire/system-target.h b/firmware/target/coldfire/system-target.h
index 9c349b1436..347d8e13dc 100644
--- a/firmware/target/coldfire/system-target.h
+++ b/firmware/target/coldfire/system-target.h
@@ -194,14 +194,7 @@ static inline uint32_t swap_odd_even32(uint32_t value)
194 return value; 194 return value;
195} 195}
196 196
197#define HAVE_INVALIDATE_ICACHE 197#define HAVE_CPUCACHE_INVALIDATE
198static inline void invalidate_icache(void)
199{
200 asm volatile ("move.l #0x01000000,%d0\n"
201 "movec.l %d0,%cacr\n"
202 "move.l #0x80000000,%d0\n"
203 "movec.l %d0,%cacr");
204}
205 198
206#define DEFAULT_PLLCR_AUDIO_BITS 0x10400000 199#define DEFAULT_PLLCR_AUDIO_BITS 0x10400000
207void coldfire_set_pllcr_audio_bits(long bits); 200void coldfire_set_pllcr_audio_bits(long bits);
diff --git a/firmware/target/sh/system-target.h b/firmware/target/sh/system-target.h
index aaf6c6bb2d..3c225fbb69 100644
--- a/firmware/target/sh/system-target.h
+++ b/firmware/target/sh/system-target.h
@@ -126,6 +126,4 @@ static inline uint32_t swap_odd_even32(uint32_t value)
126 return value; 126 return value;
127} 127}
128 128
129#define invalidate_icache()
130
131#endif /* SYSTEM_TARGET_H */ 129#endif /* SYSTEM_TARGET_H */
diff --git a/firmware/thread.c b/firmware/thread.c
index f779ca3ae0..ce78769d11 100644
--- a/firmware/thread.c
+++ b/firmware/thread.c
@@ -179,17 +179,17 @@ static void __attribute__((naked,used)) start_thread(void)
179{ 179{
180 /* r0 = context */ 180 /* r0 = context */
181 asm volatile ( 181 asm volatile (
182 "ldr sp, [r0, #32] \n" /* Load initial sp */ 182 "ldr sp, [r0, #32] \n" /* Load initial sp */
183 "ldr r4, [r0, #40] \n" /* start in r4 since it's non-volatile */ 183 "ldr r4, [r0, #40] \n" /* start in r4 since it's non-volatile */
184 "mov r1, #0 \n" /* Mark thread as running */ 184 "mov r1, #0 \n" /* Mark thread as running */
185 "str r1, [r0, #40] \n" 185 "str r1, [r0, #40] \n"
186#if NUM_CORES > 1 186#if NUM_CORES > 1
187 "ldr r0, =invalidate_icache \n" /* Invalidate this core's cache. */ 187 "ldr r0, =cpucache_invalidate \n" /* Invalidate this core's cache. */
188 "mov lr, pc \n" /* This could be the first entry into */ 188 "mov lr, pc \n" /* This could be the first entry into */
189 "bx r0 \n" /* plugin or codec code for this core. */ 189 "bx r0 \n" /* plugin or codec code for this core. */
190#endif 190#endif
191 "mov lr, pc \n" /* Call thread function */ 191 "mov lr, pc \n" /* Call thread function */
192 "bx r4 \n" 192 "bx r4 \n"
193 ); /* No clobber list - new thread doesn't care */ 193 ); /* No clobber list - new thread doesn't care */
194 thread_exit(); 194 thread_exit();
195 //asm volatile (".ltorg"); /* Dump constant pool */ 195 //asm volatile (".ltorg"); /* Dump constant pool */
@@ -668,7 +668,7 @@ static inline void switch_to_idle_stack(const unsigned int core)
668static void core_switch_blk_op(unsigned int core, struct thread_entry *thread) 668static void core_switch_blk_op(unsigned int core, struct thread_entry *thread)
669{ 669{
670 /* Flush our data to ram */ 670 /* Flush our data to ram */
671 flush_icache(); 671 cpucache_flush();
672 /* Stash thread in r4 slot */ 672 /* Stash thread in r4 slot */
673 thread->context.r[0] = (uint32_t)thread; 673 thread->context.r[0] = (uint32_t)thread;
674 /* Stash restart address in r5 slot */ 674 /* Stash restart address in r5 slot */
@@ -696,24 +696,24 @@ static void __attribute__((naked))
696 * Stack access also isn't permitted until restoring the original stack and 696 * Stack access also isn't permitted until restoring the original stack and
697 * context. */ 697 * context. */
698 asm volatile ( 698 asm volatile (
699 "stmfd sp!, { r4-r12, lr } \n" /* Stack all non-volatile context on current core */ 699 "stmfd sp!, { r4-r12, lr } \n" /* Stack all non-volatile context on current core */
700 "ldr r2, =idle_stacks \n" /* r2 = &idle_stacks[core][IDLE_STACK_WORDS] */ 700 "ldr r2, =idle_stacks \n" /* r2 = &idle_stacks[core][IDLE_STACK_WORDS] */
701 "ldr r2, [r2, r0, lsl #2] \n" 701 "ldr r2, [r2, r0, lsl #2] \n"
702 "add r2, r2, %0*4 \n" 702 "add r2, r2, %0*4 \n"
703 "stmfd r2!, { sp } \n" /* save original stack pointer on idle stack */ 703 "stmfd r2!, { sp } \n" /* save original stack pointer on idle stack */
704 "mov sp, r2 \n" /* switch stacks */ 704 "mov sp, r2 \n" /* switch stacks */
705 "adr r2, 1f \n" /* r2 = new core restart address */ 705 "adr r2, 1f \n" /* r2 = new core restart address */
706 "str r2, [r1, #40] \n" /* thread->context.start = r2 */ 706 "str r2, [r1, #40] \n" /* thread->context.start = r2 */
707 "ldr pc, =switch_thread \n" /* r0 = thread after call - see load_context */ 707 "ldr pc, =switch_thread \n" /* r0 = thread after call - see load_context */
708 "1: \n" 708 "1: \n"
709 "ldr sp, [r0, #32] \n" /* Reload original sp from context structure */ 709 "ldr sp, [r0, #32] \n" /* Reload original sp from context structure */
710 "mov r1, #0 \n" /* Clear start address */ 710 "mov r1, #0 \n" /* Clear start address */
711 "str r1, [r0, #40] \n" 711 "str r1, [r0, #40] \n"
712 "ldr r0, =invalidate_icache \n" /* Invalidate new core's cache */ 712 "ldr r0, =cpucache_invalidate \n" /* Invalidate new core's cache */
713 "mov lr, pc \n" 713 "mov lr, pc \n"
714 "bx r0 \n" 714 "bx r0 \n"
715 "ldmfd sp!, { r4-r12, pc } \n" /* Restore non-volatile context to new core and return */ 715 "ldmfd sp!, { r4-r12, pc } \n" /* Restore non-volatile context to new core and return */
716 ".ltorg \n" /* Dump constant pool */ 716 ".ltorg \n" /* Dump constant pool */
717 : : "i"(IDLE_STACK_WORDS) 717 : : "i"(IDLE_STACK_WORDS)
718 ); 718 );
719 (void)core; (void)thread; 719 (void)core; (void)thread;
@@ -2457,7 +2457,7 @@ unsigned int create_thread(void (*function)(void),
2457 /* Writeback stack munging or anything else before starting */ 2457 /* Writeback stack munging or anything else before starting */
2458 if (core != CURRENT_CORE) 2458 if (core != CURRENT_CORE)
2459 { 2459 {
2460 flush_icache(); 2460 cpucache_flush();
2461 } 2461 }
2462#endif 2462#endif
2463 2463
@@ -2597,7 +2597,7 @@ void thread_exit(void)
2597 switch_to_idle_stack(core); 2597 switch_to_idle_stack(core);
2598 } 2598 }
2599 2599
2600 flush_icache(); 2600 cpucache_flush();
2601 2601
2602 /* At this point, this thread isn't using resources allocated for 2602 /* At this point, this thread isn't using resources allocated for
2603 * execution except the slot itself. */ 2603 * execution except the slot itself. */
diff --git a/firmware/usbstack/usb_storage.c b/firmware/usbstack/usb_storage.c
index 85499c1bbd..86b47cf653 100644
--- a/firmware/usbstack/usb_storage.c
+++ b/firmware/usbstack/usb_storage.c
@@ -415,7 +415,7 @@ void usb_storage_init_connection(void)
415 audio_buffer = audio_get_buffer(false,&bufsize); 415 audio_buffer = audio_get_buffer(false,&bufsize);
416 tb.transfer_buffer = 416 tb.transfer_buffer =
417 (void *)UNCACHED_ADDR((unsigned int)(audio_buffer + 31) & 0xffffffe0); 417 (void *)UNCACHED_ADDR((unsigned int)(audio_buffer + 31) & 0xffffffe0);
418 invalidate_icache(); 418 cpucache_invalidate();
419#ifdef USB_USE_RAMDISK 419#ifdef USB_USE_RAMDISK
420 ramdisk_buffer = tb.transfer_buffer + BUFFER_SIZE*2; 420 ramdisk_buffer = tb.transfer_buffer + BUFFER_SIZE*2;
421#endif 421#endif