MIPS 4Kc Cache Initialization

Aug 21, 2005 1 Replies

Howdy,



I'm working a MIPS 4Kc-type chip from Broadcom. I'm having trouble with the cache initialization function. My code is based entirely on the code from the book _See Mips Run_. When I change_cp0_config (0x7, 3) after the setupCache() call the board reboots. Similarly, linux crashes doing its own initialization. Any ideas?



void setupCache () { register unsigned int addr, junk;



write_32bit_cp0_register (CP0_TAGLO, 0); //I-Cahce: for (addr = KSEG0; addr < KSEG0 + 0x00002000; addr += 16) { Index_Store_Tag_I(addr); Fill_I(addr); Index_Store_Tag_I(addr); } //D-Cache: for (addr = KSEG0; addr < KSEG0 + 0x00001000; addr += 16) Index_Store_Tag_D(addr); for (addr = KSEG0; addr < KSEG0 + 0x00001000; addr += 16) junk = *((unsigned int *)addr); for (addr = KSEG0; addr < KSEG0 + 0x00001000; addr += 16) Index_Store_Tag_D(addr); }



One of the macros looks like so: #define Index_Store_Tag_I(i) \ __asm__ __volatile__( \ "cache 0x08,0(%0)\n\t" \ : : "r" (i) \ );



Thanks,



Brett



Okay -- *sigh* change_cp0_config was jumping to address 0. Having said that, I adjusted things a bit:

-> I'm loading the cache code to KSEG1. It runs fine.

-> I'm running a tight loop before and after to check the runtimes against the timer. The loop is loaded in to KSEG0. The first loop runs fine uncahced. Enable cache and function begins normally without a crash (by printing 3 characters) but then dies in the loop?

Loop Without Cache: xuMON> go Running: 80010000 :0 :1

00036E08 LOOP

Loop With Cache: xuMON> go Running: 80010000 :0

Brett

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required