/* alan test */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "bspchip.h" /**************************************************************/ /*************************************************************/ //For l2cache // #define _mips_sync() __asm__ __volatile__ ("sync 0x3" : : : "memory") static int flush_l2cache(void){ unsigned long cache_size ; unsigned long linesz,sets,ways; int i; unsigned int config2; unsigned int tmp; config2 = read_c0_config2(); if (config2 & (1 << 12)) return 0; /* L2-Cache */ tmp = (config2 >> 4) & 0x0f; if (0 < tmp && tmp <= 7) linesz = 2 << tmp; else return 0; tmp = (config2 >> 8) & 0x0f; if (0 <= tmp && tmp <= 7) sets = 64 << tmp; else return 0; tmp = (config2 >> 0) & 0x0f; if (0 <= tmp && tmp <= 7) ways = tmp + 1; else return 0; cache_size = sets * ways * linesz; printk("L2cache LineSize=%lu, Sets=%lu, Ways=%lu, CacheSize=%lu\n", linesz, sets, ways, cache_size); for(i=CKSEG0; i < (CKSEG0 + cache_size); i += linesz){ cache_op(Index_Writeback_Inv_SD,i); } __sync_mem(); return 0; } static ssize_t bsp_dw_write_proc(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { char tmpbuf[32]; unsigned int addr = 0; unsigned int length = 0; unsigned type = 0; int *ptr = NULL; int i = 0; /* no data be written */ if (!count) { printk("count is 0\n"); return 0; } /* Input size is too large to write our buffer(num) */ if (count > (sizeof(tmpbuf) - 1)) { printk("input is too large\n"); return -EINVAL; } if (copy_from_user(tmpbuf, buffer, count)) { printk("copy from user failed\n"); return -EFAULT; } i = sscanf(tmpbuf, "0x%x 0x%x %d", &addr, &length, &type); printk("[CPU%d]input addr: %x, length: %x \n", smp_processor_id(),addr, length); if( (i== 1) && (addr == 1)){ flush_l2cache(); return count; } if( (addr >> 28) == 0 ){ return -EINVAL; } ptr = (int *)addr; if( i == 2 ){ for(i=0;i