Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1064044
  • 博文数量: 121
  • 博客积分: 2021
  • 博客等级: 上尉
  • 技术积分: 1467
  • 用 户 组: 普通用户
  • 注册时间: 2009-06-29 21:47
个人简介

简约而不简单。

文章分类

全部博文(121)

文章存档

2017年(1)

2016年(4)

2015年(2)

2014年(24)

2013年(33)

2012年(13)

2011年(25)

2010年(13)

2009年(6)

分类: LINUX

2013-04-15 23:30:58

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


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