我知道mmu通过转换表(或tcl中存储的虚拟地址表)来查找物理内存,可是我不了解mmu如何初始化转换表的??
void MMU_Init(void)
{
int i,j;
//========================== IMPORTANT NOTE =========================
//The current stack and code area can't be re-mapped in this routine.
//If you want memory map mapped freely, your own sophiscated MMU
//initialization code is needed.
//===================================================================
MMU_DisableDCache();//关数据缓存
MMU_DisableICache();//关指令缓存
//If write-back is used,the DCache should be cleared.
for(i=0;i<64;i++)//64是什么意思?
for(j=0;j<8;j++)//8是什么意思?
MMU_CleanInvalidateDCacheIndex((i<<26)|(j<<5));//字面意思:清除无效的数据缓存的索引??
MMU_InvalidateICache();//使指令缓存无效,这里和MMU_DisableICache()区别是什么?
#if 0
//To complete MMU_Init() fast, Icache may be turned on here.
MMU_EnableICache();
#endif
MMU_DisableMMU();//关mmu
MMU_InvalidateTLB();//令tcb无效。
//MMU_SetMTT(int vaddrStart,int vaddrEnd,int paddrStart,int attr)
// MMU_SetMTT(0x00000000,0x07f00000,0x00000000,RW_NCNB); //bank0
MMU_SetMTT(0x00000000,0x00100000,(U32)__ENTRY,RW_CB); //bank0 when no nor flash, must do this
//!!! Important note, redirect IRQ vector to reset entry !!!
MMU_SetMTT(0x04000000,0x07f00000,0x00000000,RW_NCNB); //bank0
MMU_SetMTT(0x08000000,0x0ff00000,0x08000000,RW_NCNB); //bank1
MMU_SetMTT(0x10000000,0x17f00000,0x10000000,RW_NCNB); //bank2
MMU_SetMTT(0x18000000,0x1ff00000,0x18000000,RW_NCNB); //bank3
MMU_SetMTT(0x20000000,0x27f00000,0x20000000,RW_NCNB); //bank4
MMU_SetMTT(0x28000000,0x2ff00000,0x28000000,RW_NCNB); //bank5
MMU_SetMTT(0x30000000,0x30100000,0x30000000,RW_CB); //bank6-1
// MMU_SetMTT(0x30000000,0x30200000,0x30000000,RW_CB); //bank6-1
MMU_SetMTT(0x30200000,0x33e00000,0x30200000,(AP_RO|DOMAIN0|NCNB|DESC_SEC)); //bank6-2
MMU_SetMTT(0x33f00000,0x33f00000,0x33f00000,RW_CB); //bank6-3
MMU_SetMTT(0x38000000,0x3ff00000,0x38000000,RW_NCNB); //bank7
MMU_SetMTT(0x40000000,0x47f00000,0x40000000,RW_NCNB); //SFR
MMU_SetMTT(0x48000000,0x5af00000,0x48000000,RW_NCNB); //SFR
MMU_SetMTT(0x5b000000,0xfff00000,0x5b000000,RW_FAULT);//not used
内存映射(节映射,一个节1MB)
MMU_SetTTBase(_MMUTT_STARTADDRESS);//设定转换表存放在内存中的首地址??
MMU_SetDomain(0x55555550|DOMAIN1_ATTR|DOMAIN0_ATTR); //???
//DOMAIN1: no_access, DOMAIN0,2~15=client(AP is checked)
MMU_SetProcessId(0x0);//???
MMU_EnableAlignFault();//???
MMU_EnableMMU();//使能mmu
MMU_EnableICache();//使能指令缓存
MMU_EnableDCache(); //使能数据缓存//DCache should be turned on after MMU is turned on.
}
//这个函数做的应该是节映射访问对吗??
void MMU_SetMTT(int vaddrStart,int vaddrEnd,int paddrStart,int attr)
{
U32 *pTT;
int i,nSec;
//pTT这个地址应该是指向存储虚拟地址所对应的物理地址的存储单元 ??
pTT=(U32 *)_MMUTT_STARTADDRESS+(vaddrStart>>20);//转换表首地址加上虚拟地址所在的节索引(这里说节对吗,1MB的存储块)
nSec=(vaddrEnd>>20)-(vaddrStart>>20);//获得有多少节
for(i=0;i<=nSec;i++)*pTT++=attr |(((paddrStart>>20)+i)<<20);//在存储单元中写入物理地址的前12位,attr是一些寄存信息
}