diff options
| author | Urey <[email protected]> | 2017-09-06 11:16:51 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-09-06 11:16:51 +0800 |
| commit | ad1d3375f222c5746514ab16003dc18c0df83dad (patch) | |
| tree | 4572af3fcf6b592a714e2ec76b25dae27a1ecea6 /libcpu/mips | |
| parent | 94746d8e5f69b26535f75b730e7540caf42863fa (diff) | |
| parent | bc225a5ef05a9b14dd72286402093cbb7dba8305 (diff) | |
Merge pull request #1 from RT-Thread/master
同步 rt-thread master
Diffstat (limited to 'libcpu/mips')
| -rw-r--r-- | libcpu/mips/loongson_1c/cpuport.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/libcpu/mips/loongson_1c/cpuport.c b/libcpu/mips/loongson_1c/cpuport.c index 6cdae024c4..f4914dfec4 100644 --- a/libcpu/mips/loongson_1c/cpuport.c +++ b/libcpu/mips/loongson_1c/cpuport.c @@ -121,5 +121,41 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter, rt_uint8_t *stack_ad return (rt_uint8_t *)stk; } +#define cache_op(op,addr) \ + __asm__ __volatile__( \ + " .set push \n" \ + " .set noreorder \n" \ + " .set mips3\n\t \n" \ + " cache %0, %1 \n" \ + " .set pop \n" \ + : \ + : "i" (op), "R" (*(unsigned char *)(addr))) + +#if defined(CONFIG_CPU_LOONGSON2) +#define Hit_Invalidate_I 0x00 +#else +#define Hit_Invalidate_I 0x10 +#endif +#define Hit_Invalidate_D 0x11 +#define CONFIG_SYS_CACHELINE_SIZE 32 +#define Hit_Writeback_Inv_D 0x15 + + +void flush_cache(unsigned long start_addr, unsigned long size) +{ + unsigned long lsize = CONFIG_SYS_CACHELINE_SIZE; + unsigned long addr = start_addr & ~(lsize - 1); + unsigned long aend = (start_addr + size - 1) & ~(lsize - 1); + + while (1) { + cache_op(Hit_Writeback_Inv_D, addr); + cache_op(Hit_Invalidate_I, addr); + if (addr == aend) + break; + addr += lsize; + } +} + + /*@}*/ |
