以下功能在附件的程序中验证,用GEC2410V1.1开发板。
文件说明:
1、S3C2410A.S: 启动文件,该文件调用M其中MMUGEN.C产生MMU页表,并可选择是否把BANI0映射到SDRAM的0X30000000处。
2、MMU.C:完成MMU的初始化
3、MMUGEN.C:根据MMU.DEF产生MMU页表,页表基地址是:0X33FC0000,由于MMUGEN.C是在地址重定位前完成的,所以用SCATTER文件把MMUGEN.C中的RW域加载到固定时域,并且不能使用全局变量,原因同上。
S3C2410A有16K的指令CACHE和16K的数据CACHE.复位时都是DISABLED状态.ICACHE,DCACHE,和MMU分别有以下组合:
1.ICACHE ENABLE,MMU ENABLE:此时根据MMU TTB各个ENTRY的''C'位决定是否在该REGION有ICACHE功能.
2.ICACHE ENABLE,MMU DISABLE: 所有地址都有ICACHE动能.
3.ICACHE DISABLE: 所有ICACHE禁止.
4.DCACHE DISABLE,MMU ENABLE: 所有DCACHE禁止.
5.MMU DISABLE: 所有DCACHE禁止.
6.DCACHE ENABLE, MMU ENABLE:根据MMU TTB各个ENTRY的''C'位决定是否在该REGION有DCACHE功能.
MMU.C中的MMU_INIT(),可以分别使能或禁止ICACHE,DCAHE和MMU.
MMU.DEF:可以设置MMU TTB中各个ENTRY的C,B功能.
通过LED_C.C中的跑马灯程序,可以清楚的验证各种组合的效果:
1.ICACHE有效时,跑马灯快N倍.
2.DCACHE有效时,跑马灯快M倍
3.把I/O口地址0X48000000-0X60000000映射成CACHEABLE(通过MMU.DEF定义),跑马灯消失,因为CPU把数据写回到CACHE中了,而没有实际写入I/O口。所以,很多向I/O一类的地址是不能CACHEABLE的。
//========================================================
MMU.C:
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++)
{
for(j=0;j<8;j++)
{
MMU_CleanInvalidateDCacheIndex((i<<26)|(j<<5));
}
}
MMU_InvalidateICache();
#if 0
//To complete MMU_Init() fast, Icache may be turned on here.
MMU_EnableICache();
#endif
MMU_DisableMMU();
MMU_InvalidateTLB();
mmugen();
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_EnableICache();
MMU_EnableDCache(); //DCache should be turned on after MMU is turned on.
}
//=============================================================
MMU.DEF:
char RuleData[]=
{
"BASE_ADDRESS 0x33fc0000\n" /* table generated to this base address */
/* MMU Level 1 Table generation data */
"LEVEL 1\n"
/* 1MB FLASH mapped to RAM */ "VIRTUAL 0x00000000 TO 0x000FFFFF PHYSICAL 0x00000000 PAGES\n"
/* 1MB FLASH mapped 1->1 */ "VIRTUAL 0x00100000 TO 0x001FFFFF PHYSICAL 0x00100000 SECTION FULL_ACCESS NOT CACHEABLE AND NOT BUFFERABLE\n"
/* Gap to 0x30000000 */ "VIRTUAL 0x00200000 TO 0x2FFFFFFF PHYSICAL 0x00200000 FAULT\n"
/* 64M SDRAM mapped 1->1 */ "VIRTUAL 0x30000000 TO 0x33FFFFFF PHYSICAL 0x30000000 SECTION FULL_ACCESS CACHEABLE AND NOT BUFFERABLE\n"
/* Gap to 0x40000000 */ "VIRTUAL 0x34000000 TO 0x3FFFFFFF PHYSICAL 0x34000000 FAULT\n"
/* 4K BOOTSAM */ "VIRTUAL 0x40000000 TO 0x400FFFFF PHYSICAL 0x40000000 PAGES\n"
/* Gap to 0x48000000 */ "VIRTUAL 0x40100000 TO 0x47FFFFFF PHYSICAL 0x40100000 FAULT\n"
/* SYSTEM REGISTER */ "VIRTUAL 0x48000000 TO 0x5FFFFFFF PHYSICAL 0x48000000 SECTION FULL_ACCESS NOT CACHEABLE AND BUFFERABLE\n"
/* Remaining space unused */ "VIRTUAL 0x60000000 TO 0xFFFFFFFF PHYSICAL 0x60000000 FAULT\n"
"LEVEL 2\n"
/* FLASH shadow image */ "VIRTUAL 0x00000000 TO 0x000FFFFF PHYSICAL 0x30000000 LARGEPAGES FULL_ACCESS NOT CACHEABLE AND NOT BUFFERABLE\n"
/* 4K BOOTSRAM */ "VIRTUAL 0x40000000 TO 0x40000FFF PHYSICAL 0x40000000 SMALLPAGES FULL_ACCESS NOT CACHEABLE AND NOT BUFFERABLE\n"
/* not use */ "VIRTUAL 0x40001000 TO 0x400FFFFF PHYSICAL 0x40001000 SMALLPAGES NO_ACCESS NOT CACHEABLE AND NOT BUFFERABLE\n"
/* for startup, first entry has to be patched to run from FLASH (as this table has yet to be copied to RAM) */
"POSTPROCESS ENTRY 0x00000000 EQUALS 0x00000C1E\n"
};
文章评论(0条评论)
登录后参与讨论