标签:font sign long ble ati mcr mmu asm class
void create_page_table(void)
{
unsigned long *ttb = (unsigned long *)0x20000000;
unsigned long vaddr, paddr;
vaddr = 0xA0000000; // 虚拟地址
paddr = 0xE0200000; //页表地址,存在内存里的
*(ttb + (vaddr >> 20)) = (paddr & 0xFFF00000) | MMU_SECDESC; // 虚拟地址映射
vaddr = 0x20000000; //内存映射
paddr = 0x20000000; //内存映射时,虚拟和物理地址一致
while (vaddr < 0x24000000)
{
*(ttb + (vaddr >> 20)) = (paddr & 0xFFF00000) | MMU_SECDESC_WB;
vaddr += 0x100000; //一页对应1M ,采用循环语句把64M映射好
paddr += 0x100000;
}
}
////////////////////////////////////////////////////////////////////////
void mmu_init()
{
__asm__(
/*设置TTB*/
"ldr r0, =0x20000000\n" //c2是Translation table base ,把地址写入c2中
"mcr p15, 0, r0, c2, c0, 0\n"
/*不进行权限检查*/
"mvn r0, #0\n" //取反传送
"mcr p15, 0, r0, c3, c0, 0\n" //c3 Domain access control 寄存器
/*使能MMU*/
"mrc p15, 0, r0, c1, c0, 0\n" //c1 是mmu的控制寄存器
"orr r0, r0, #0x0001\n"
"mcr p15, 0, r0, c1, c0, 0\n"
:
:
);
}
标签:font sign long ble ati mcr mmu asm class
原文地址:http://www.cnblogs.com/1932238825qq/p/7141940.html