资源描述:
《arm linux源代码分析(1)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、ARMLinux源代码分析(1)/*ARMLinux源代码分析(1)--head.STigerZ(tigerz@yeah.net)http://emblinux.org/1.分析环境 kernel:2.6.10 board:SMDK24101.32,64MSDRAM,128MSM卡2.head.S*//* *linux/arch/arm/kernel/head.S * * Copyright(C)1994-2002RussellKing * *Thisprogramisfreesoftware;youcanred
2、istributeitand/ormodify *itunderthetermsoftheGNUGeneralPublicLicenseversion2as *publishedbytheFreeSoftwareFoundation. * * Kernelstartupcodeforall32-bitCPUs */#include#include#include#include#include<
3、asm/mach-types.h>#include#include#include#ifndefCONFIG_XIP_KERNEL/*我在的平台,这个宏没有定义*//* *Weplacethepagetables16KbelowTEXTADDR. Therefore,wemustmakesure *thatTEXTADDRiscorrectlyset. Currently,weexpecttheleastsignificant
4、*16bitstobe0x8000,butwecouldprobablyrelaxthisrestrictionto *TEXTADDR>=PAGE_OFFSET+0x4000 * *页表放在比TEXTADDR低16K的地方,所以我们必须要确认TEXTADDR被正确设定.目前, *我们希望低16位为0x8000,不过我们可以放松这个限制为 *TEXTADDR>=PAGE_OFFSET+0x4000 * *Notethatswapper_pg_diristhevirtualaddressofthepagetables,an
5、d *pgtblgivesusaposition-independentreferencetothesetables. Wecan *dothisbecausestext==TEXTADDR * *注意swapper_pg_dir是页表的虚拟地址,pgtbl给我们一个位置无关的页表地址,这是 *因为stext==TEXTADDR. */#if(TEXTADDR&0xffff)!=0x8000 #errorTEXTADDRmuststartat0xXXXX8000#endif /*swapper_pg_dir=0x
6、30008000-0x4000*/ .globl swapper_pg_dir .equ swapper_pg_dir,TEXTADDR-0x4000 /*rd=stext-0x4000,这里stext==TEXTADDR*/ /*adr指令是在pc值上+/-一个标号的偏移得到的,所以得到的地址只跟pc和标号到 *pc的偏移相关,跟编译地址无关.在MMU打开前,代码要是地址无关的,会经常 *用到adr. */ .macro pgtbl,rd,phys adr rd,s
7、text sub rd,rd,#0x4000 .endm#else/**XIPKernel:**Weplacethepagetables16KbelowDATAADDR. Therefore,wemustmakesure*thatDATAADDRiscorrectlyset. Currently,weexpecttheleastsignificant*16bitstobe0x8000,butwecouldprobablyrelaxthisrestrictionto*DATAADDR>=PAGE_OFFS
8、ET+0x4000**Notethatpgtblismeanttoreturnthephysicaladdressofswapper_pg_dir.*Wecan'tmakeitrelativetothekernelpositioninthiscasesince*thekernelcanphysicallybeanyw