Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1844858
  • 博文数量: 317
  • 博客积分: 1557
  • 博客等级: 上尉
  • 技术积分: 1208
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-26 23:38
个人简介

如果想出发,就不要等到明天!

文章分类

全部博文(317)

文章存档

2016年(1)

2015年(41)

2014年(152)

2013年(114)

2012年(4)

2011年(1)

2009年(4)

分类: LINUX

2013-04-17 17:27:10

原文地址:uboot中MMU地址映射 作者:cnscgyl

1.uboot的页表位置:lowlevel_init.S文件的最后:、
    /* form a first-level section entry */
.macro FL_SECTION_ENTRY base,ap,d,c,b
.word (\base << 20) | (\ap << 10) | \
     (\d << 5) | (1<<4) | (\c << 3) | (\b << 2) | (1<<1)
.endm //以上是宏定义

.section .mmudata, "a"
.align 14// the following alignment creates the mmu table at address 0x4000=2^14 16K对齐.

.globl mmu_table
mmu_table:
.set __base,0
// 1:1 mapping for debugging
.rept 0xA00 
FL_SECTION_ENTRY __base,3,0,0,0
.set __base,__base+1
.endr


// access is not allowed.
.rept 0xC00 - 0xA00
.word 0x00000000
.endr

        // 128MB or 256MB for SDRAM 0xC0000000 -> 0x50000000
.set __base, 0x500 //地址映射
    #ifdef FORLINX_BOOT_RAM128
        .rept 0xC80 - 0xC00
    #else
        .rept 0xD00 - 0xC00
    #endif
FL_SECTION_ENTRY __base,3,0,1,1
.set __base,__base+1
.endr
/ /access is not allowed.
    #ifdef FORLINX_BOOT_RAM128
        .rept 0x1000 - 0xC80
    #else
        .rept 0x1000 - 0xD00
    #endif
.word 0x00000000
.endr

2. 如何查找也基地址?
    在uboot的第二阶段启动MMU。在start.S文件中:
    1)定义页表地址:
#ifdef CONFIG_ENABLE_MMU
_mmu_table_base:
.word mmu_table
#endif
    2)讲页表地址送入P15的C2寄存器:
#ifdef CONFIG_ENABLE_MMU
enable_mmu:
/* enable domain access */
ldr r5, =0x0000ffff
mcr p15, 0, r5, c3, c0, 0 @ load domain access register
 /* Set the TTB register */
ldr r0, _mmu_table_base
ldr r1, =CFG_PHY_UBOOT_BASE
ldr r2, =0xfff00000
bic r0, r0, r2
orr r1, r0, r1
mcr p15, 0, r1, c2, c0, 0
 /* Enable the MMU */
mmu_on:
mrc p15, 0, r0, c1, c0, 0
orr r0, r0, #1 /* Set CR_M to enable MMU */
mcr p15, 0, r0, c1, c0, 0
nop
nop
nop
nop
#endif


阅读(4117) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~