Commit to certain names for cache coherency APIs and discard the aliases.

Wouldn't surprise me a bit to get some non-green.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31339 a1c6a512-1295-4272-9138-f99709370657
diff --git a/apps/codec_thread.c b/apps/codec_thread.c
index 0498858..39db741 100644
--- a/apps/codec_thread.c
+++ b/apps/codec_thread.c
@@ -550,9 +550,9 @@
 
     if (callback)
     {
-        cpucache_commit_discard();
+        commit_discard_idcache();
         callback();
-        cpucache_commit();
+        commit_dcache();
     }
 }
 
diff --git a/apps/codecs.c b/apps/codecs.c
index 93542e3..fafe4ac 100644
--- a/apps/codecs.c
+++ b/apps/codecs.c
@@ -116,8 +116,8 @@
     semaphore_release,
 #endif
 
-    cpucache_flush,
-    cpucache_invalidate,
+    commit_dcache,
+    commit_discard_dcache,
 
     /* strings and memory */
     strcpy,
@@ -165,6 +165,8 @@
 
     /* new stuff at the end, sort into place next time
        the API gets incompatible */
+
+    commit_discard_idcache,
 };
 
 void codec_get_full_path(char *path, const char *codec_root_fn)
diff --git a/apps/codecs.h b/apps/codecs.h
index f1e2a51..1334953 100644
--- a/apps/codecs.h
+++ b/apps/codecs.h
@@ -75,7 +75,7 @@
 #define CODEC_ENC_MAGIC 0x52454E43 /* RENC */
 
 /* increase this every time the api struct changes */
-#define CODEC_API_VERSION 43
+#define CODEC_API_VERSION 44
 
 /* update this to latest version if a change to the api struct breaks
    backwards compatibility (and please take the opportunity to sort in any
@@ -169,8 +169,8 @@
     void (*semaphore_release)(struct semaphore *s);
 #endif /* NUM_CORES */
 
-    void (*cpucache_flush)(void);
-    void (*cpucache_invalidate)(void);
+    void (*commit_dcache)(void);
+    void (*commit_discard_dcache)(void);
 
     /* strings and memory */
     char* (*strcpy)(char *dst, const char *src);
@@ -223,6 +223,7 @@
 
     /* new stuff at the end, sort into place next time
        the API gets incompatible */
+    void (*commit_discard_idcache)(void);
 };
 
 /* codec header */
diff --git a/apps/codecs/codec_crt0.c b/apps/codecs/codec_crt0.c
index 50a2d8b..e3c3321 100644
--- a/apps/codecs/codec_crt0.c
+++ b/apps/codecs/codec_crt0.c
@@ -45,7 +45,7 @@
             ci->memcpy(iramstart, iramcopy, iram_size);
             ci->memset(iedata, 0, ibss_size);
             /* make the icache (if it exists) up to date with the new code */
-            ci->cpucache_invalidate();
+            ci->commit_discard_idcache();
             /* barrier to prevent reordering iram copy and BSS clearing,
              * because the BSS segment alias the IRAM copy.
              */
@@ -56,7 +56,7 @@
         /* Some parts of bss may be used via a no-cache alias (at least
          * portalplayer has this). If we don't clear the cache, those aliases
          * may read garbage */
-        ci->cpucache_invalidate();
+        ci->commit_dcache();
     }
 #endif /* CONFIG_PLATFORM */
 
diff --git a/apps/codecs/mpa.c b/apps/codecs/mpa.c
index ac81f06..f9bf7e6 100644
--- a/apps/codecs/mpa.c
+++ b/apps/codecs/mpa.c
@@ -274,7 +274,7 @@
     die = 1;
     ci->semaphore_release(&synth_pending_sem);
     ci->thread_wait(mad_synth_thread_id);
-    ci->cpucache_invalidate();
+    ci->commit_discard_dcache();
 }
 #else
 static inline void mad_synth_thread_ready(void)
diff --git a/apps/codecs/spc.c b/apps/codecs/spc.c
index 94ac9ff..809562e 100644
--- a/apps/codecs/spc.c
+++ b/apps/codecs/spc.c
@@ -295,7 +295,7 @@
     if (id == SPC_EMU_LOAD)
     {
         struct spc_load *ld = (struct spc_load *)chunk->data;
-        ci->cpucache_invalidate();
+        ci->commit_discard_dcache();
         SPC_Init(&spc_emu);
         sample_queue.retval = SPC_load_spc(&spc_emu, ld->buf, ld->size);
 
@@ -368,7 +368,7 @@
 static inline int load_spc_buffer(uint8_t *buf, size_t size)
 {
     struct spc_load ld = { buf, size };
-    ci->cpucache_flush();
+    ci->commit_dcache();
     return emu_thread_send_msg(SPC_EMU_LOAD, (intptr_t)&ld);
 }
 
@@ -378,7 +378,7 @@
         emu_thread_send_msg(SPC_EMU_QUIT, 0);
         /* Wait for emu thread to be killed */
         ci->thread_wait(emu_thread_id);
-        ci->cpucache_invalidate();
+        ci->commit_discard_dcache();
     }
 }
 
diff --git a/apps/plugin.c b/apps/plugin.c
index f5aa589..6dd84af 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -428,8 +428,8 @@
     cancel_cpu_boost,
 #endif
 
-    cpucache_flush,
-    cpucache_invalidate,
+    commit_dcache,
+    commit_discard_dcache,
 
     lc_open,
     lc_open_from_mem,
@@ -794,6 +794,8 @@
 
     /* new stuff at the end, sort into place next time
        the API gets incompatible */
+
+    commit_discard_idcache,
 };
 
 int plugin_load(const char* plugin, const void* parameter)
diff --git a/apps/plugin.h b/apps/plugin.h
index e2b7fe7..4a62697 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -148,7 +148,7 @@
 #define PLUGIN_MAGIC 0x526F634B /* RocK */
 
 /* increase this every time the api struct changes */
-#define PLUGIN_API_VERSION 214
+#define PLUGIN_API_VERSION 215
 
 /* update this to latest version if a change to the api struct breaks
    backwards compatibility (and please take the opportunity to sort in any
@@ -513,8 +513,8 @@
     void (*cancel_cpu_boost)(void);
 #endif
 
-    void (*cpucache_flush)(void);
-    void (*cpucache_invalidate)(void);
+    void (*commit_dcache)(void);
+    void (*commit_discard_dcache)(void);
 
     /* load code api for overlay */
     void* (*lc_open)(const char *filename, unsigned char *buf, size_t buf_size);
@@ -948,7 +948,8 @@
 
     /* new stuff at the end, sort into place next time
        the API gets incompatible */
-    
+
+    void (*commit_discard_idcache)(void);
 };
 
 /* plugin header */
diff --git a/apps/plugins/fft/fft.c b/apps/plugins/fft/fft.c
index 11bdfc8..8920550 100644
--- a/apps/plugins/fft/fft.c
+++ b/apps/plugins/fft/fft.c
@@ -1249,7 +1249,7 @@
         }
 
         /* write back output for other processor and invalidate for next frame read */
-        rb->cpucache_invalidate();
+        rb->commit_discard_dcache();
 
         int new_tail = output_tail ^ 1;
 
@@ -1311,7 +1311,7 @@
     /* Handle our FFT thread. */
     fft_thread_run = false;
     rb->thread_wait(fft_thread);
-    rb->cpucache_invalidate();
+    rb->commit_discard_dcache();
 }
 #else /* NUM_CORES == 1 */
 /* everything serialize on single-core and FFT gets to use IRAM main stack if
diff --git a/apps/plugins/mpegplayer/alloc.c b/apps/plugins/mpegplayer/alloc.c
index c2165b2..eb58c67 100644
--- a/apps/plugins/mpegplayer/alloc.c
+++ b/apps/plugins/mpegplayer/alloc.c
@@ -149,7 +149,7 @@
         return false;
     }
 
-    IF_COP(rb->cpucache_invalidate());
+    IF_COP(rb->commit_discard_dcache());
     return true;
 }
 
diff --git a/apps/plugins/mpegplayer/video_thread.c b/apps/plugins/mpegplayer/video_thread.c
index 5119712..392cc61 100644
--- a/apps/plugins/mpegplayer/video_thread.c
+++ b/apps/plugins/mpegplayer/video_thread.c
@@ -550,7 +550,7 @@
             }
             else
             {
-                IF_COP(rb->cpucache_invalidate());
+                IF_COP(rb->commit_discard_dcache());
                 vo_lock();
                 rb->lcd_update();
                 vo_unlock();
@@ -1007,7 +1007,7 @@
 {
     intptr_t rep;
 
-    IF_COP(rb->cpucache_flush());
+    IF_COP(rb->commit_dcache());
 
     video_str.hdr.q = &video_str_queue;
     rb->queue_init(video_str.hdr.q, false);
@@ -1025,7 +1025,7 @@
 
     /* Wait for thread to initialize */
     rep = str_send_msg(&video_str, STREAM_NULL, 0);
-    IF_COP(rb->cpucache_invalidate());
+    IF_COP(rb->commit_discard_dcache());
 
     return rep == 0; /* Normally STREAM_NULL should be ignored */
 }
@@ -1037,7 +1037,7 @@
     {
         str_post_msg(&video_str, STREAM_QUIT, 0);
         rb->thread_wait(video_str.thread);
-        IF_COP(rb->cpucache_invalidate());
+        IF_COP(rb->commit_discard_dcache());
         video_str.thread = 0;
     }
 }
diff --git a/apps/plugins/plugin_crt0.c b/apps/plugins/plugin_crt0.c
index 917ccb1..680bb07 100644
--- a/apps/plugins/plugin_crt0.c
+++ b/apps/plugins/plugin_crt0.c
@@ -76,10 +76,8 @@
         rb->audio_stop();
         rb->memcpy(iramstart, iramcopy, iram_size);
         rb->memset(iedata, 0, ibss_size);
-#ifdef HAVE_CPUCACHE_INVALIDATE
         /* make the icache (if it exists) up to date with the new code */
-        rb->cpucache_invalidate();
-#endif /* HAVE_CPUCACHE_INVALIDATE */
+        rb->commit_discard_idcache();
 
         /* barrier to prevent reordering iram copy and BSS clearing,
          * because the BSS segment alias the IRAM copy.
@@ -91,12 +89,10 @@
     /* zero out the bss section */
     rb->memset(plugin_bss_start, 0, plugin_end_addr - plugin_bss_start);
 
-#ifdef HAVE_CPUCACHE_INVALIDATE
     /* Some parts of bss may be used via a no-cache alias (at least
      * portalplayer has this). If we don't clear the cache, those aliases
      * may read garbage */
-    rb->cpucache_invalidate();
-#endif /* HAVE_CPUCACHE_INVALIDATE */
+    rb->commit_dcache();
 #endif
 
     /* we come back here if exit() was called or the plugin returned normally */
diff --git a/bootloader/gigabeat-s.c b/bootloader/gigabeat-s.c
index 223d839..8483170 100644
--- a/bootloader/gigabeat-s.c
+++ b/bootloader/gigabeat-s.c
@@ -324,7 +324,7 @@
 
     if (rc == EOK)
     {
-        cpucache_commit_discard();
+        commit_discard_idcache();
         asm volatile ("bx %0": : "r"(start_addr));
     }
 
diff --git a/bootloader/gigabeat.c b/bootloader/gigabeat.c
index cfba4bb..fb03f0e 100644
--- a/bootloader/gigabeat.c
+++ b/bootloader/gigabeat.c
@@ -195,7 +195,7 @@
     printf("Loading firmware");
 
     /* Flush out anything pending first */
-    cpucache_invalidate();
+    commit_discard_idcache();
 
     loadbuffer = (unsigned char*) 0x31000000;
     buffer_size = (unsigned char*)0x31400000 - loadbuffer;
@@ -209,7 +209,7 @@
 
     if (rc == EOK)
     {
-        cpucache_invalidate();
+        commit_discard_idcache();
         kernel_entry = (void*) loadbuffer;
         rc = kernel_entry();
     }
diff --git a/firmware/export/load_code.h b/firmware/export/load_code.h
index 55ce601..6f8505a 100644
--- a/firmware/export/load_code.h
+++ b/firmware/export/load_code.h
@@ -35,7 +35,7 @@
 {
     (void)blob_size;
     /* commit dcache and discard icache */
-    cpucache_invalidate();
+    commit_discard_idcache();
     return addr;
 }
 static inline void *lc_get_header(void *handle) { return handle; }
diff --git a/firmware/export/system.h b/firmware/export/system.h
index aa07994..1055c65 100644
--- a/firmware/export/system.h
+++ b/firmware/export/system.h
@@ -302,35 +302,6 @@
 #define DISABLE_INTERRUPTS  HIGHEST_IRQ_LEVEL
 #endif
 
-/* Just define these as empty if not declared */
-#ifdef HAVE_CPUCACHE_INVALIDATE
-void cpucache_commit_discard(void);
-/* deprecated alias */
-void cpucache_invalidate(void);
-#else
-static inline void cpucache_commit_discard(void)
-{
-}
-/* deprecated alias */
-static inline void cpucache_invalidate(void)
-{
-}
-#endif
-
-#ifdef HAVE_CPUCACHE_FLUSH
-void cpucache_commit(void);
-/* deprecated alias */
-void cpucache_flush(void);
-#else
-static inline void cpucache_commit(void)
-{
-}
-/* deprecated alias */
-static inline void cpucache_flush(void)
-{
-}
-#endif
-
 /* Define this, if the CPU may take advantage of cache aligment. Is enabled
  * for all ARM CPUs. */
 #ifdef CPU_ARM
diff --git a/firmware/load_code.c b/firmware/load_code.c
index 59eb7ac..a76aca3 100644
--- a/firmware/load_code.c
+++ b/firmware/load_code.c
@@ -46,7 +46,6 @@
     /* Make sure COP cache is flushed and invalidated before loading */
     {
         int my_core = switch_core(CURRENT_CORE ^ 1);
-        cpucache_commit_discard();
         switch_core(my_core);
     }
 #endif
@@ -89,7 +88,7 @@
     }
 
     /* commit dcache and discard icache */
-    cpucache_commit_discard();
+    commit_discard_idcache();
     /* return a pointer the header, reused by lc_get_header() */
     return hdr.load_addr;
 
diff --git a/firmware/rolo.c b/firmware/rolo.c
index 283779d..3569746 100644
--- a/firmware/rolo.c
+++ b/firmware/rolo.c
@@ -75,7 +75,7 @@
     COP_INT_DIS = -1;
 
     /* Invalidate cache */
-    cpucache_invalidate();
+    commit_discard_idcache();
     
     /* Disable cache */
     CACHE_CTL = CACHE_CTL_DISABLE;
@@ -148,7 +148,7 @@
     CPU_INT_DIS = -1;
 
     /* Flush cache */
-    cpucache_flush();
+    commit_discard_idcache();
 
     /* Disable cache */
     CACHE_CTL = CACHE_CTL_DISABLE;
@@ -174,10 +174,8 @@
     );
 
 #elif defined(CPU_ARM)
-#ifdef HAVE_CPUCACHE_INVALIDATE
     /* Flush and invalidate caches */
-    cpucache_invalidate();
-#endif
+    commit_discard_idcache();
     asm volatile(
         "bx    %0   \n"
         : : "r"(dest)
diff --git a/firmware/target/arm/as3525/pcm-as3525.c b/firmware/target/arm/as3525/pcm-as3525.c
index b33ea2a..0ecc63d 100644
--- a/firmware/target/arm/as3525/pcm-as3525.c
+++ b/firmware/target/arm/as3525/pcm-as3525.c
@@ -109,7 +109,7 @@
         dma_rem_size = dma_start_size;
 
         /* force writeback */
-        clean_dcache_range(dma_start_addr, dma_start_size);
+        commit_dcache_range(dma_start_addr, dma_start_size);
         play_start_pcm();
         pcm_play_dma_started_callback();
     }
@@ -131,7 +131,7 @@
     dma_retain();
 
     /* force writeback */
-    clean_dcache_range(dma_start_addr, dma_start_size);
+    commit_dcache_range(dma_start_addr, dma_start_size);
 
     bitset32(&CGU_AUDIO, (1<<11));
 
diff --git a/firmware/target/arm/as3525/usb-drv-as3525.c b/firmware/target/arm/as3525/usb-drv-as3525.c
index 1f52d40..d619a01 100644
--- a/firmware/target/arm/as3525/usb-drv-as3525.c
+++ b/firmware/target/arm/as3525/usb-drv-as3525.c
@@ -432,7 +432,7 @@
     endpoints[ep][1].rc  = -1;
 
     /* remove data buffer from cache */
-    invalidate_dcache_range(ptr, len);
+    discard_dcache_range(ptr, len);
 
     /* DMA setup */
     uc_desc->status    = USB_DMA_DESC_BS_HST_RDY |
@@ -509,7 +509,7 @@
         USB_IEP_CTRL(ep) |= USB_EP_CTRL_FLUSH;
 
     /* Make sure data is committed to memory */
-    clean_dcache_range(ptr, len);
+    commit_dcache_range(ptr, len);
 
     logf("xx%s\n", make_hex(ptr, len));
 
@@ -625,7 +625,7 @@
              /*
               * If parts of the just dmaed range are in cache, dump them now.
               */
-             dump_dcache_range(uc_desc->data_ptr, dma_len);
+             discard_dcache_range(uc_desc->data_ptr, dma_len);
         } else{
              logf("EP%d OUT token, st:%08x frm:%x (no data)\n", ep,
                  dma_sts & 0xf8000000, (dma_sts >> 16) & 0x7ff);
diff --git a/firmware/target/arm/as3525/usb-drv-as3525v2.c b/firmware/target/arm/as3525/usb-drv-as3525v2.c
index 7b5ce88..c0542d5 100644
--- a/firmware/target/arm/as3525/usb-drv-as3525v2.c
+++ b/firmware/target/arm/as3525/usb-drv-as3525v2.c
@@ -449,9 +449,9 @@
         : (void*)0x10000000;
     DEPTSIZ(ep, out) = (nb_packets << DEPTSIZ_pkcnt_bitp) | len;
     if(out)
-        dump_dcache_range(ptr, len);
+        discard_dcache_range(ptr, len);
     else
-        clean_dcache_range(ptr, len);
+        commit_dcache_range(ptr, len);
 
     logf("pkt=%d dma=%lx", nb_packets, DEPDMA(ep, out));
 
diff --git a/firmware/target/arm/ata-pp5020.c b/firmware/target/arm/ata-pp5020.c
index 50e6e27..50a38cb 100644
--- a/firmware/target/arm/ata-pp5020.c
+++ b/firmware/target/arm/ata-pp5020.c
@@ -181,11 +181,11 @@
 
     if (write) {
         /* If unflushed, old data may be written to disk */
-        cpucache_flush();
+        commit_dcache();
     }
     else {
         /* Invalidate cache because new data may be present in RAM */
-        cpucache_invalidate();
+        commit_discard_dcache();
     }
 
     /* Clear pending interrupts so ata_dma_finish() can wait for an
diff --git a/firmware/target/arm/imx31/ata-imx31.c b/firmware/target/arm/imx31/ata-imx31.c
index 80539b9..3b08a38 100644
--- a/firmware/target/arm/imx31/ata-imx31.c
+++ b/firmware/target/arm/imx31/ata-imx31.c
@@ -475,7 +475,7 @@
         if (LIKELY(buf != addr))
         {
             /* addr is virtual */
-            clean_dcache_range(addr, bytes);
+            commit_dcache_range(addr, bytes);
         }
 
         /* Setup ATA controller for DMA transmit */
@@ -495,7 +495,7 @@
         if (LIKELY(buf != addr))
         {
             /* addr is virtual */
-            dump_dcache_range(addr, bytes);
+            discard_dcache_range(addr, bytes);
 
             if ((unsigned long)addr & 31)
             {
diff --git a/firmware/target/arm/imx31/crt0.S b/firmware/target/arm/imx31/crt0.S
index b6a4926..1c1ae55 100644
--- a/firmware/target/arm/imx31/crt0.S
+++ b/firmware/target/arm/imx31/crt0.S
@@ -301,7 +301,7 @@
 #endif
 
     /* Make memory coherent for devices */
-    bl      cpucache_commit_discard
+    bl      commit_discard_idcache
 
     bl      main
 
diff --git a/firmware/target/arm/imx31/gigabeat-s/pcm-gigabeat-s.c b/firmware/target/arm/imx31/gigabeat-s/pcm-gigabeat-s.c
index 180a0fe..e106cf7 100644
--- a/firmware/target/arm/imx31/gigabeat-s/pcm-gigabeat-s.c
+++ b/firmware/target/arm/imx31/gigabeat-s/pcm-gigabeat-s.c
@@ -99,7 +99,7 @@
         return;
 
      /* Flush any pending cache writes */
-    clean_dcache_range(start, size);
+    commit_dcache_range(start, size);
     dma_play_bd.buf_addr = (void *)addr_virt_to_phys((unsigned long)start);
     dma_play_bd.mode.count = size;
     dma_play_bd.mode.command = TRANSFER_16BIT;
@@ -202,7 +202,7 @@
         unsigned long dsa = 0;
         dma_play_bd.buf_addr = NULL;
         dma_play_bd.mode.count = 0;
-        clean_dcache_range(&dsa, sizeof(dsa));
+        discard_dcache_range(&dsa, sizeof(dsa));
         sdma_write_words(&dsa, CHANNEL_CONTEXT_ADDR(DMA_PLAY_CH_NUM)+0x0b, 1);
     }
 
@@ -221,7 +221,7 @@
     if (!sdma_channel_reset(DMA_PLAY_CH_NUM))
         return;
 
-    clean_dcache_range(addr, size);
+    commit_dcache_range(addr, size);
     dma_play_bd.buf_addr =
         (void *)addr_virt_to_phys((unsigned long)(void *)addr);
     dma_play_bd.mode.count = size;
@@ -353,7 +353,7 @@
         return;
 
     /* Invalidate - buffer must be coherent */
-    dump_dcache_range(start, size);
+    discard_dcache_range(start, size);
 
     start = (void *)addr_virt_to_phys((unsigned long)start);
 
@@ -412,7 +412,7 @@
         unsigned long pda = 0;
         dma_rec_bd.buf_addr = NULL;
         dma_rec_bd.mode.count = 0;
-        clean_dcache_range(&pda, sizeof(pda));
+        discard_dcache_range(&pda, sizeof(pda));
         sdma_write_words(&pda, CHANNEL_CONTEXT_ADDR(DMA_REC_CH_NUM)+0x0a, 1);
     }
 
@@ -428,7 +428,7 @@
         return;
     
     /* Invalidate - buffer must be coherent */
-    dump_dcache_range(addr, size);
+    discard_dcache_range(addr, size);
 
     addr = (void *)addr_virt_to_phys((unsigned long)addr);
     dma_rec_bd.buf_addr = addr;
diff --git a/firmware/target/arm/imx31/sdma-imx31.c b/firmware/target/arm/imx31/sdma-imx31.c
index 68aa0aa..d3e6233 100644
--- a/firmware/target/arm/imx31/sdma-imx31.c
+++ b/firmware/target/arm/imx31/sdma-imx31.c
@@ -382,7 +382,7 @@
     }
 
     /* Send channel context to SDMA core */
-    clean_dcache_range(&context_buffer, sizeof (context_buffer));
+    commit_dcache_range(&context_buffer, sizeof (context_buffer));
     sdma_write_words((unsigned long *)&context_buffer,
                      CHANNEL_CONTEXT_ADDR(channel),
                      sizeof (context_buffer)/4);
diff --git a/firmware/target/arm/mmu-arm.S b/firmware/target/arm/mmu-arm.S
index 88f9095..522aa9f 100644
--- a/firmware/target/arm/mmu-arm.S
+++ b/firmware/target/arm/mmu-arm.S
@@ -184,11 +184,9 @@
     .align      2
     .global     commit_discard_dcache_range
     .type       commit_discard_dcache_range, %function
-    .global     invalidate_dcache_range @ Alias, deprecated
 
     @ MVA format: 31:5 = Modified virtual address, 4:0 = SBZ
 commit_discard_dcache_range:
-invalidate_dcache_range:
     add     r1, r0, r1              @ size -> end
     cmp     r1, r0                  @ end <= start?
     bxls    lr                      @
@@ -232,11 +230,9 @@
     .align      2
     .global     commit_dcache_range
     .type       commit_dcache_range, %function
-    .global     clean_dcache_range  @ Alias, deprecated
 
     @ MVA format: 31:5 = Modified virtual address, 4:0 = SBZ
 commit_dcache_range:
-clean_dcache_range:
     add     r1, r0, r1              @ size -> end
     cmp     r1, r0                  @ end <= start?
     bxls    lr                      @
@@ -281,11 +277,9 @@
     .align      2
     .global     discard_dcache_range
     .type       discard_dcache_range, %function
-    .global     dump_dcache_range   @ Alias, deprecated
 
     @ MVA format: 31:5 = Modified virtual address, 4:0 = SBZ
 discard_dcache_range:
-dump_dcache_range:
     add     r1, r0, r1              @ size -> end
     cmp     r1, r0                  @ end <= start?
     bxls    lr                      @
@@ -339,14 +333,8 @@
     .align      2
     .global     commit_dcache
     .type       commit_dcache, %function
-    .global     cpucache_commit     @ Alias
-    .global     clean_dcache        @ Alias, deprecated
-    .global     cpucache_flush      @ Alias, deprecated
 
 commit_dcache:
-cpucache_commit:
-clean_dcache:
-cpucache_flush:
 #ifdef HAVE_TEST_AND_CLEAN_CACHE
     mrc     p15, 0, r15, c7, c10, 3 @ test and clean dcache
     bne     commit_dcache
@@ -376,10 +364,8 @@
     .align      2
     .global     commit_discard_dcache
     .type       commit_discard_dcache, %function
-    .global     invalidate_dcache   @ Alias, deprecated
 
 commit_discard_dcache:
-invalidate_dcache:
 #ifdef HAVE_TEST_AND_CLEAN_CACHE
     mrc     p15, 0, r15, c7, c14, 3 @ test, clean and invalidate dcache
     bne     commit_discard_dcache
@@ -409,14 +395,8 @@
     .align      2
     .global     commit_discard_idcache
     .type       commit_discard_idcache, %function
-    .global     cpucache_commit_discard @ Alias
-    .global     invalidate_idcache      @ Alias, deprecated
-    .global     cpucache_invalidate     @ Alias, deprecated
 
 commit_discard_idcache:
-cpucache_commit_discard:
-invalidate_idcache:
-cpucache_invalidate:
     mov     r2, lr                  @ save lr to r1, call uses r0 only
     bl      commit_discard_dcache   @ commit and discard entire DCache
     mcr     p15, 0, r1, c7, c5, 0   @ Invalidate ICache (r1=0 from call)
diff --git a/firmware/target/arm/mmu-arm.h b/firmware/target/arm/mmu-arm.h
index 92a81c0..1557694 100644
--- a/firmware/target/arm/mmu-arm.h
+++ b/firmware/target/arm/mmu-arm.h
@@ -53,42 +53,24 @@
 
 /* Commits entire DCache */
 void commit_dcache(void);
-/* deprecated alias */
-void clean_dcache(void);
 
 /* Commit and discard entire DCache, will do writeback */
 void commit_discard_dcache(void);
-/* deprecated alias */
-void invalidate_dcache(void);
 
 /* Write DCache back to RAM for the given range and remove cache lines
  * from DCache afterwards */
 void commit_discard_dcache_range(const void *base, unsigned int size);
-/* deprecated alias */
-void invalidate_dcache_range(const void *base, unsigned int size);
 
 /* Write DCache back to RAM for the given range */
 void commit_dcache_range(const void *base, unsigned int size);
-/* deprecated alias */
-void clean_dcache_range(const void *base, unsigned int size);
 
 /*
  * Remove cache lines for the given range from DCache
  * will *NOT* do write back except for buffer edges not on a line boundary
  */
 void discard_dcache_range(const void *base, unsigned int size);
-/* deprecated alias */
-void dump_dcache_range(const void *base, unsigned int size);
 
 /* Discards the entire ICache, and commit+discards the entire DCache */
 void commit_discard_idcache(void);
-/* deprecated alias */
-void invalidate_idcache(void);
-
-#define HAVE_CPUCACHE_COMMIT_DISCARD
-#define HAVE_CPUCACHE_COMMIT
-/* deprecated alias */
-#define HAVE_CPUCACHE_INVALIDATE
-#define HAVE_CPUCACHE_FLUSH
 
 #endif /* MMU_ARM_H */
diff --git a/firmware/target/arm/mmu-armv6.S b/firmware/target/arm/mmu-armv6.S
index c4cb49e..30d719d 100644
--- a/firmware/target/arm/mmu-armv6.S
+++ b/firmware/target/arm/mmu-armv6.S
@@ -36,11 +36,9 @@
     .align      2
     .global     commit_discard_dcache_range
     .type       commit_discard_dcache_range, %function
-    .global     invalidate_dcache_range @ Alias, deprecated
 
     @ MVA format: 31:5 = Modified virtual address, 4:0 = SBZ
 commit_discard_dcache_range:
-invalidate_dcache_range:
     add     r1, r0, r1              @ size -> end
     cmp     r1, r0                  @ end <= start?
     subhi   r1, r1, #1              @ round it down
@@ -60,11 +58,9 @@
     .align      2
     .global     commit_dcache_range
     .type       commit_dcache_range, %function
-    .global     clean_dcache_range  @ Alias, deprecated
 
     @ MVA format: 31:5 = Modified virtual address, 4:0 = SBZ
 commit_dcache_range:
-clean_dcache_range:
     add     r1, r0, r1              @ size -> end
     cmp     r1, r0                  @ end <= start?
     subhi   r1, r1, #1              @ round it down
@@ -83,11 +79,9 @@
     .align      2
     .global     discard_dcache_range
     .type       discard_dcache_range, %function
-    .global     dump_dcache_range   @ Alias, deprecated
 
     @ MVA format: 31:5 = Modified virtual address, 4:0 = SBZ
 discard_dcache_range:
-dump_dcache_range:
     add     r1, r0, r1              @ size -> end
     cmp     r1, r0                  @ end <= start?
     bxls    lr                      @
@@ -118,14 +112,8 @@
     .align      2
     .global     commit_dcache
     .type       commit_dcache, %function
-    .global     cpucache_commit     @ Alias
-    .global     clean_dcache        @ Alias, deprecated
-    .global     cpucache_flush      @ Alias, deprecated
 
 commit_dcache:
-cpucache_commit:
-clean_dcache:
-cpucache_flush:
     mov     r0, #0                  @
     mcr     p15, 0, r0, c7, c10, 0  @ Clean entire DCache
     mcr     p15, 0, r0, c7, c10, 4  @ Data synchronization barrier
@@ -140,10 +128,8 @@
     .align      2
     .global     commit_discard_dcache
     .type       commit_discard_dcache, %function
-    .global     invalidate_dcache   @ Alias, deprecated
 
 commit_discard_dcache:
-invalidate_dcache:
     mov     r0, #0                  @
     mcr     p15, 0, r0, c7, c14, 0  @ Clean and invalidate entire DCache
     mcr     p15, 0, r0, c7, c10, 4  @ Data synchronization barrier
@@ -153,20 +139,14 @@
 
 /*
  * Discards the entire ICache, and commit+discards the entire DCache
- * void cpucache_commit_discard(void);
+ * void commit_discard_idcache(void);
  */
-    .section   .icode.cpucache_commit_discard, "ax", %progbits
+    .section   .icode.commit_discard_idcache, "ax", %progbits
     .align      2
-    .global     cpucache_commit_discard
-    .type       cpucache_commit_discard, %function
-    .global     commit_discard_idcache  @ Alias
-    .global     invalidate_idcache      @ Alias, deprecated
-    .global     cpucache_invalidate     @ Alias, deprecated
+    .global     commit_discard_idcache
+    .type       commit_discard_idcache, %function
 
-cpucache_commit_discard:
 commit_discard_idcache:
-invalidate_idcache:
-cpucache_invalidate:
     mov     r0, #0                  @
     mcr     p15, 0, r0, c7, c14, 0  @ Clean and invalidate entire DCache
     mcr     p15, 0, r0, c7, c5, 0   @ Invalidate entire ICache
diff --git a/firmware/target/arm/pcm-pp.c b/firmware/target/arm/pcm-pp.c
index 695bc71..3854206 100644
--- a/firmware/target/arm/pcm-pp.c
+++ b/firmware/target/arm/pcm-pp.c
@@ -158,7 +158,7 @@
         if (dma_play_data.addr < UNCACHED_BASE_ADDR) {
             /* Flush any pending cache writes */
             dma_play_data.addr = UNCACHED_ADDR(dma_play_data.addr);
-            cpucache_flush();
+            commit_discard_idcache();
         }
     }
 }
@@ -444,7 +444,7 @@
     if ((unsigned long)addr < UNCACHED_BASE_ADDR) {
         /* Flush any pending cache writes */
         addr = UNCACHED_ADDR(addr);
-        cpucache_flush();
+        commit_discard_idcache();
     }
 
     dma_play_data.addr = (unsigned long)addr;
diff --git a/firmware/target/arm/rk27xx/system-rk27xx.c b/firmware/target/arm/rk27xx/system-rk27xx.c
index e73edf1..3349f9d 100644
--- a/firmware/target/arm/rk27xx/system-rk27xx.c
+++ b/firmware/target/arm/rk27xx/system-rk27xx.c
@@ -163,7 +163,7 @@
     );
 }
 
-void cpucache_commit_discard(void)
+void commit_discard_idcache(void)
 {
     /* invalidate cache way 0 */
     CACHEOP = 0x02;
@@ -178,8 +178,6 @@
     while (CACHEOP & 0x03);   
 }
 
-void cpucache_invalidate(void) __attribute__((alias("cpucache_commit_discard")));
-
 void commit_discard_dcache_range (const void *base, unsigned int size)
 {
     int cnt = size + ((unsigned long)base & 0x1f);
@@ -196,4 +194,5 @@
     }
 }
 
-void clean_dcache_range(const void *base, unsigned int size) __attribute__((alias("commit_discard_dcache_range")));
+void commit_dcache_range(const void *base, unsigned int size)
+    __attribute__((alias("commit_discard_dcache_range")));
diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/ata-meg-fx.c b/firmware/target/arm/s3c2440/gigabeat-fx/ata-meg-fx.c
index 89b00bb..aae4c4b 100644
--- a/firmware/target/arm/s3c2440/gigabeat-fx/ata-meg-fx.c
+++ b/firmware/target/arm/s3c2440/gigabeat-fx/ata-meg-fx.c
@@ -121,7 +121,8 @@
     /* Activate the channel */
     DMASKTRIG0 = 0x2;
 
-    invalidate_dcache_range((void *)buf, wordcount*2);
+    /* Dump cache for the buffer  */
+    discard_dcache_range((void *)buf, wordcount*2);
 
     /* Start DMA */
     DMASKTRIG0 |= 0x1;
@@ -129,6 +130,5 @@
     /* Wait for transfer to complete */
     while((DSTAT0 & 0x000fffff))
         yield();
-    /* Dump cache for the buffer  */
 }
 #endif
diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/pcm-meg-fx.c b/firmware/target/arm/s3c2440/gigabeat-fx/pcm-meg-fx.c
index b133639..3590564 100644
--- a/firmware/target/arm/s3c2440/gigabeat-fx/pcm-meg-fx.c
+++ b/firmware/target/arm/s3c2440/gigabeat-fx/pcm-meg-fx.c
@@ -111,7 +111,7 @@
     SRCPND = DMA2_MASK;
 
     /* Flush any pending writes */
-    clean_dcache_range((char*)DISRC2-0x30000000, (DCON2 & 0xFFFFF) * 2);
+    commit_dcache_range((char*)DISRC2-0x30000000, (DCON2 & 0xFFFFF) * 2);
 
     /* unmask DMA interrupt when unlocking */
     dma_play_lock.state = DMA2_MASK;
@@ -228,7 +228,7 @@
         return;
 
     /* Flush any pending cache writes */
-    clean_dcache_range(start, size);
+    commit_dcache_range(start, size);
 
     /* set the new DMA values */
     DCON2 = DMA_CONTROL_SETUP | (size >> 1);
diff --git a/firmware/target/arm/s3c2440/mini2440/pcm-mini2440.c b/firmware/target/arm/s3c2440/mini2440/pcm-mini2440.c
index 20332c1..a4f58a8 100644
--- a/firmware/target/arm/s3c2440/mini2440/pcm-mini2440.c
+++ b/firmware/target/arm/s3c2440/mini2440/pcm-mini2440.c
@@ -146,7 +146,7 @@
     SRCPND = DMA2_MASK;
 
     /* Flush any pending writes */
-    clean_dcache_range((char*)DISRC2-0x30000000, (DCON2 & 0xFFFFF) * 2);
+    commit_dcache_range((char*)DISRC2-0x30000000, (DCON2 & 0xFFFFF) * 2);
 
     /* unmask DMA interrupt when unlocking */
     dma_play_lock.state = DMA2_MASK;
@@ -268,7 +268,7 @@
         return;
 
     /* Flush any pending cache writes */
-    clean_dcache_range(start, size);
+    commit_dcache_range(start, size);
 
     /* set the new DMA values */
     DCON2 = DMA_CONTROL_SETUP | (size >> 1);
diff --git a/firmware/target/arm/system-pp5002.c b/firmware/target/arm/system-pp5002.c
index 04e052f..3186d37 100644
--- a/firmware/target/arm/system-pp5002.c
+++ b/firmware/target/arm/system-pp5002.c
@@ -54,15 +54,8 @@
 
 #endif
 
-/* TODO: The following two function have been lifted straight from IPL, and
-   hence have a lot of numeric addresses used straight. I'd like to use
-   #defines for these, but don't know what most of them are for or even what
-   they should be named. Because of this I also have no way of knowing how
-   to extend the funtions to do alternate cache configurations and/or
-   some other CPU frequency scaling. */
-
 #ifndef BOOTLOADER
-void ICODE_ATTR __attribute__((naked)) cpucache_commit(void)
+void ICODE_ATTR __attribute__((naked)) commit_dcache(void)
 {
     asm volatile(
         "mov    r0, #0xf0000000 \n"
@@ -76,9 +69,8 @@
         "bx     lr              \n"
     );
 }
-void cpucache_flush(void) __attribute__((alias("cpucache_commit")));
 
-void ICODE_ATTR  __attribute__((naked)) cpucache_commit_discard(void)
+void ICODE_ATTR  __attribute__((naked)) commit_discard_idcache(void)
 {
     asm volatile(
         "mov    r0, #0xf0000000 \n"
@@ -94,7 +86,8 @@
         "bx     lr              \n"
     );
 }
-void cpucache_invalidate(void) __attribute__((alias("cpucache_commit_discard")));
+
+void commit_discard_dcache(void) __attribute__((alias("commit_discard_idcache")));
 
 static void ipod_init_cache(void)
 {
diff --git a/firmware/target/arm/system-pp502x.c b/firmware/target/arm/system-pp502x.c
index 0422ea7..08c2719 100644
--- a/firmware/target/arm/system-pp502x.c
+++ b/firmware/target/arm/system-pp502x.c
@@ -209,7 +209,7 @@
     GPIOL_INT_EN        = 0;
 }
 
-void ICODE_ATTR cpucache_commit(void)
+void ICODE_ATTR commit_dcache(void)
 {
     if (CACHE_CTL & CACHE_CTL_ENABLE)
     {
@@ -218,9 +218,8 @@
         nop; nop; nop; nop;
     }
 }
-void cpucache_flush(void) __attribute__((alias("cpucache_commit")));
 
-void ICODE_ATTR cpucache_commit_discard(void)
+void ICODE_ATTR commit_discard_idcache(void)
 {
     if (CACHE_CTL & CACHE_CTL_ENABLE)
     {
@@ -229,7 +228,8 @@
         nop; nop; nop; nop;
     }
 }
-void cpucache_invalidate(void) __attribute__((alias("cpucache_commit_discard")));
+
+void commit_discard_dcache(void) __attribute__((alias("commit_discard_idcache")));
 
 static void init_cache(void)
 {
diff --git a/firmware/target/arm/system-target.h b/firmware/target/arm/system-target.h
index e5a8b15..730bc2d 100644
--- a/firmware/target/arm/system-target.h
+++ b/firmware/target/arm/system-target.h
@@ -141,6 +141,10 @@
 }
 #endif
 
+void commit_dcache(void);
+void commit_discard_dcache(void);
+void commit_discard_idcache(void);
+
 #if defined(BOOTLOADER) && !defined(HAVE_BOOTLOADER_USB_MODE)
 /* All addresses within rockbox are in IRAM in the bootloader so
    are therefore uncached */
@@ -162,15 +166,6 @@
 #define STORAGE_WANTS_ALIGN
 #endif
 
-/** cache functions **/
-#if !defined(BOOTLOADER) || defined(HAVE_BOOTLOADER_USB_MODE)
-#define HAVE_CPUCACHE_COMMIT_DISCARD
-#define HAVE_CPUCACHE_COMMIT
-/* deprecated alias */
-#define HAVE_CPUCACHE_INVALIDATE
-#define HAVE_CPUCACHE_FLUSH
-#endif
-
 #if defined(IPOD_VIDEO) && !defined(BOOTLOADER)
 extern unsigned char probed_ramsize;
 int battery_default_capacity(void);
diff --git a/firmware/target/arm/thread-arm.c b/firmware/target/arm/thread-arm.c
index e1bbc04..0b46ca2 100644
--- a/firmware/target/arm/thread-arm.c
+++ b/firmware/target/arm/thread-arm.c
@@ -34,7 +34,7 @@
         "mov    r1, #0                   \n" /* Mark thread as running */
         "str    r1, [r0, #40]            \n"
 #if NUM_CORES > 1
-        "ldr    r0, =cpucache_invalidate \n" /* Invalidate this core's cache. */
+        "ldr    r0, =commit_discard_idcache \n" /* Invalidate this core's cache. */
         "mov    lr, pc                   \n" /* This could be the first entry into */
         "bx     r0                       \n" /* plugin or codec code for this core. */
 #endif
diff --git a/firmware/target/arm/thread-pp.c b/firmware/target/arm/thread-pp.c
index a0a4d4f..0836b27 100644
--- a/firmware/target/arm/thread-pp.c
+++ b/firmware/target/arm/thread-pp.c
@@ -214,7 +214,7 @@
 {
     asm volatile (
         "cmp    %1, #0               \n" /* CPU? */
-        "ldrne  r0, =cpucache_flush  \n" /* No? write back data */
+        "ldrne  r0, =commit_dcache   \n" /* No? write back data */
         "movne  lr, pc               \n"
         "bxne   r0                   \n"
         "mov    r0, %0               \n" /* copy thread parameter */
@@ -244,7 +244,7 @@
 static void core_switch_blk_op(unsigned int core, struct thread_entry *thread)
 {
     /* Flush our data to ram */
-    cpucache_flush();
+    commit_dcache();
     /* Stash thread in r4 slot */
     thread->context.r[0] = (uint32_t)thread;
     /* Stash restart address in r5 slot */
@@ -285,7 +285,7 @@
         "ldr    sp, [r0, #32]            \n" /* Reload original sp from context structure */
         "mov    r1, #0                   \n" /* Clear start address */
         "str    r1, [r0, #40]            \n"
-        "ldr    r0, =cpucache_invalidate \n" /* Invalidate new core's cache */
+        "ldr    r0, =commit_discard_idcache \n" /* Invalidate new core's cache */
         "mov    lr, pc                   \n"
         "bx     r0                       \n"
         "ldmfd  sp!, { r4-r11, pc }      \n" /* Restore non-volatile context to new core and return */
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c
index 94163ed..8980139 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c
@@ -318,7 +318,7 @@
     dst     =   (char *)FRAME + (y * LCD_HEIGHT + x) * pix_width;
                     
     /* Flush the area that is being copied from. */
-    clean_dcache_range(src, (stride*pix_width*width));
+    commit_dcache_range(src, (stride*pix_width*width));
     
     /* Addresses are relative to start of SDRAM */
     src     -=  CONFIG_SDRAM_START;
@@ -393,9 +393,9 @@
                 * pix_width;
     
     /* Flush the area that is being copied from. */
-    clean_dcache();
+    commit_dcache();
     
-//    clean_dcache_range(src, (stride*pix_width*width));
+//    commit_dcache_range(src, (stride*pix_width*width));
     
     /* Addresses are relative to start of SDRAM */
     src     -=  CONFIG_SDRAM_START;
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/pcm-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/pcm-mr500.c
index c507428..91d6b66 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/pcm-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/pcm-mr500.c
@@ -170,7 +170,7 @@
         {
             unsigned long sdem_addr=(unsigned long)start - CONFIG_SDRAM_START;
             /* Flush any pending cache writes */
-            clean_dcache_range(start, size);
+            commit_dcache_range(start, size);
 
             /* set the new DMA values */
             DSP_(_sdem_addrl) = sdem_addr & 0xffff;
diff --git a/firmware/target/arm/tms320dm320/sansa-connect/pcm-sansaconnect.c b/firmware/target/arm/tms320dm320/sansa-connect/pcm-sansaconnect.c
index 3f04838..045f7b0 100644
--- a/firmware/target/arm/tms320dm320/sansa-connect/pcm-sansaconnect.c
+++ b/firmware/target/arm/tms320dm320/sansa-connect/pcm-sansaconnect.c
@@ -180,7 +180,7 @@
         {
             unsigned long sdem_addr=(unsigned long)start - CONFIG_SDRAM_START;
             /* Flush any pending cache writes */
-            clean_dcache_range(start, size);
+            commit_dcache_range(start, size);
 
             /* set the new DMA values */
             DSP_(_sdem_addrl) = sdem_addr & 0xffff;
diff --git a/firmware/target/coldfire/system-coldfire.c b/firmware/target/coldfire/system-coldfire.c
index 4f7ac43..ed130fc 100644
--- a/firmware/target/coldfire/system-coldfire.c
+++ b/firmware/target/coldfire/system-coldfire.c
@@ -384,12 +384,10 @@
     restore_irq(level);
 }
 
-void cpucache_commit_discard(void)
+void commit_discard_idcache(void)
 {
    asm volatile ("move.l #0x01000000,%d0\n"
                  "movec.l %d0,%cacr\n"
                  "move.l #0x80000000,%d0\n"
                  "movec.l %d0,%cacr");
 }
-
-void cpucache_invalidate(void) __attribute__((alias("cpucache_commit_discard")));
diff --git a/firmware/target/coldfire/system-target.h b/firmware/target/coldfire/system-target.h
index 3d7502a..74767c4 100644
--- a/firmware/target/coldfire/system-target.h
+++ b/firmware/target/coldfire/system-target.h
@@ -194,10 +194,6 @@
     return value;
 }
 
-#define HAVE_CPUCACHE_COMMIT_DISCARD
-/* deprecated alias */
-#define HAVE_CPUCACHE_INVALIDATE
-
 #define DEFAULT_PLLCR_AUDIO_BITS 0x10400000
 void coldfire_set_pllcr_audio_bits(long bits);
 
@@ -223,4 +219,8 @@
 #define CPUFREQ_MAX_MULT     11
 #define CPUFREQ_MAX          (CPUFREQ_MAX_MULT * CPU_FREQ)
 
+void commit_discard_idcache(void);
+static inline void commit_discard_dcache(void) {}
+static inline void commit_dcache(void) {}
+
 #endif /* SYSTEM_TARGET_H */
diff --git a/firmware/target/hosted/android/system-target.h b/firmware/target/hosted/android/system-target.h
index 325c101..12610de 100644
--- a/firmware/target/hosted/android/system-target.h
+++ b/firmware/target/hosted/android/system-target.h
@@ -26,6 +26,10 @@
 #define disable_irq_save() 0
 #define restore_irq(level) (void)level
 
+static inline void commit_dcache(void) {}
+static inline void commit_discard_dcache(void) {}
+static inline void commit_discard_idcache(void) {}
+
 void power_off(void);
 void wait_for_interrupt(void);
 void interrupt(void);
diff --git a/firmware/target/hosted/sdl/system-sdl.h b/firmware/target/hosted/sdl/system-sdl.h
index 9021a12..d607e5e 100644
--- a/firmware/target/hosted/sdl/system-sdl.h
+++ b/firmware/target/hosted/sdl/system-sdl.h
@@ -57,4 +57,8 @@
 extern int display_zoom;
 extern long start_tick;
 
+static inline void commit_dcache(void) {}
+static inline void commit_discard_dcache(void) {}
+static inline void commit_discard_idcache(void) {}
+
 #endif /* _SYSTEM_SDL_H_ */
diff --git a/firmware/target/mips/mmu-mips.c b/firmware/target/mips/mmu-mips.c
index 31b0740..9dcec43 100644
--- a/firmware/target/mips/mmu-mips.c
+++ b/firmware/target/mips/mmu-mips.c
@@ -169,12 +169,6 @@
         : "r" (i));
 }
 
-void cpucache_commit_discard(void)
-{
-    __icache_invalidate_all();
-}
-void cpucache_invalidate(void) __attribute__((alias("cpucache_commit_discard")));
-
 void __dcache_invalidate_all(void)
 {
     unsigned int i;
diff --git a/firmware/target/mips/mmu-mips.h b/firmware/target/mips/mmu-mips.h
index f3d35f6..47aea80 100644
--- a/firmware/target/mips/mmu-mips.h
+++ b/firmware/target/mips/mmu-mips.h
@@ -37,4 +37,8 @@
 void __flush_dcache_line(unsigned long addr);
 void dma_cache_wback_inv(unsigned long addr, unsigned long size);
 
+#define commit_discard_idcache  __icache_invalidate_all
+#define commit_discard_dcache   __dcache_invalidate_all
+#define commit_dcache           __dcache_writeback_all
+
 #endif /* __MMU_MIPS_INCLUDE_H */
diff --git a/firmware/target/sh/system-target.h b/firmware/target/sh/system-target.h
index d78c058..5db9cc0 100644
--- a/firmware/target/sh/system-target.h
+++ b/firmware/target/sh/system-target.h
@@ -133,4 +133,8 @@
     : bit_n_table[n] \
 )
 
+static inline void commit_dcache(void) {}
+static inline void commit_discard_dcache(void) {}
+static inline void commit_discard_idcache(void) {}
+
 #endif /* SYSTEM_TARGET_H */
diff --git a/firmware/thread.c b/firmware/thread.c
index 251646b..732675a 100644
--- a/firmware/thread.c
+++ b/firmware/thread.c
@@ -1613,7 +1613,7 @@
     /* Writeback stack munging or anything else before starting */
     if (core != CURRENT_CORE)
     {
-        cpucache_flush();
+        commit_discard_idcache();
     }
 #endif
 
diff --git a/firmware/usbstack/usb_storage.c b/firmware/usbstack/usb_storage.c
index 0b9e6a9..c156d80 100644
--- a/firmware/usbstack/usb_storage.c
+++ b/firmware/usbstack/usb_storage.c
@@ -474,7 +474,7 @@
     cbw_buffer = (void *)((unsigned int)(audio_buffer+31) & 0xffffffe0);
 #endif
     tb.transfer_buffer = cbw_buffer + MAX_CBW_SIZE;
-    cpucache_invalidate();
+    commit_discard_dcache();
 #ifdef USB_USE_RAMDISK
     ramdisk_buffer = tb.transfer_buffer + ALLOCATE_BUFFER_SIZE;
 #endif