浅析armlinux-setup_arch()->clear_mapping()函数5-2-1
文章来源:
http://gliethttp.cublog.cn
建议首先参考《浅析armlinux2_4_19启动程式[
head-
armv.
s文档]
》[
http://gliethttp.cublog.cn]
//----------------------------------------
//arch/arm/mm/Mm-armv.c->clear_mapping()
static inline void clear_mapping(unsigned long virt)
{//对于2级小页映射方式,一级页目录和二级目录其实是相同的
pmd_clear(pmd_offset(pgd_offset_k(virt), virt));
}
//include/asm-arm/Pgtable.h有如下定义
#define pgd_index(addr) ((addr) >> PGDIR_SHIFT)
#define pgd_offset(mm, addr) ((mm)->pgd+pgd_index(addr))
#define pgd_offset_k(addr) pgd_offset(&init_mm, addr)
//include/asm-arm/Pgtable.h有如下定义
#define pmd_clear(pmdp) set_pmd(pmdp, __pmd(0))
//include/asm-arm/proc-armv/Pgtable.h有如下定义
#define set_pmd(pmdp,pmd) cpu_set_pmd(pmdp,pmd)
//include/asm-arm/cpu-single.h中有如下定义
#define cpu_set_pmd cpu_fn(CPU_NAME,_set_pmd)
翻译之后
#define cpu_set_pmd cpu_arm920_set_pmd
相应的
#define cpu_set_pgd cpu_arm920_set_pgd
#define cpu_set_pmd cpu_arm920_set_pmd
#define cpu_set_pte cpu_arm920_set_pte
以上三个函数位于arch/arm/mm/proc-arm920.S
//swapper_pg_dir[4k]
.align 5
ENTRY(cpu_arm920_set_pmd)
str r1, [r0]
mcr p15, 0, r0, c7, c10, 1//清除D入口
mcr p15, 0, r0, c7, c10, 4//WB开漏
mov pc, lr