1. Yes you can use L1 cache for both ROM and RAM
2. L1 cache initialization is quite simple - you need only to enable and invalidate. Below is a part of L1 cache initialization from cache.c file distributed with our CodeWarrior
void l1_cache_init()
{
// Enable and Invalidate L1 DataCache
asm("mfspr r5,1010"); /* Read in L1CSR0 spr contents */
asm("ori r5,r5,0x0003"); /* Set CE and CFI bit */
asm("andi. r6,r5,0xFFFD"); /* Clear the CFI bit for the final store */
asm("mtspr 1010,r5");
asm("isync");
asm("isync");
asm("mtspr 1010,r6"); /* Store the final value */
asm("isync");
asm("isync");
//Enable and Invalidate Inst Cache
asm("mfspr r5,1011"); /* Read in L1CSR1 spr contents */
asm("ori r5,r5,0x0003"); /* Set ICE and ICFI bit */
asm("andi. r6,r5,0xFFFD"); /* Clear the CFI bit for the final store */
asm("mtspr 1011,r5");
asm("isync");
asm("isync");
asm("mtspr 1011,r6"); /* Store the final value */
asm("isync");
asm("isync");
}
Have a great day,
Alexander
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------