Linux内核配置文件之解读Makefile

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

vivi与Linuxkernel的参数传递情景分析收藏在上一部分提到过了,vivi作为bootloader,向内核传递启动参数是其本职工作之一。要把这个情景分析清楚,不仅仅需要分析vivi的参数机制,而且要分析Linuxkernel的接收机制。因为这是一个简单的通信过程,比起本科所学习的TCP/IP来简单的多,但是因为简单,所以在协议上并不规范,理解上反而不如TCP/IP协议。下面就分为两个方面对此情景分析。一、综述内核参数传递机制现在内核参数传递机制有两种:一种是基于structparam_struct,这种已经比较老了。缺点是该结构每个成员的位置是固定的,受限比较大。另外一种就是新的structtagway。说新是相对的,Linuxkernel2.4.x都希望采用这种tag的方式。关于这方面的资料,可以有如下参考(所给出的目录是基于linux-2.4.18的内核,以顶层Makefile所在目录为当前目录。这里基于ARM架构的S3C2410,其他的SoC可以类比很容易得到):1、关于bootloader的理解--【Documentation/arm/booting】此文档详细的讲述了bootloader的作用,具体内容如下:[armlinux@lqmarm]$catBootingBootingARMLinux=================Author:RussellKingDate:18May2002Thefollowingdocumentationisrelevantto2.4.18-rmk6andbeyond.InordertobootARMLinux,yourequireabootloader,whichisasmallprogramthatrunsbeforethemainkernel.Thebootloaderisexpectedtoinitialisevariousdevices,andeventuallycalltheLinuxkernel,passinginformationtothekernel.Essentially,thebootloadershouldprovide(asaminimum)thefollowing:1.SetupandinitialisetheRAM.2.Initialiseoneserialport.3.Detectthemachinetype.4.Setupthekerneltaggedlist.5.Callthekernelimage.1.SetupandinitialiseRAM---------------------------Existingbootloaders:MANDATORYNewbootloaders:MANDATORYThebootloaderisexpectedtofindandinitialiseallRAMthatthekernelwilluseforvolatiledatastorageinthesystem.Itperformsthisinamachinedependentmanner.(ItmayuseinternalalgorithmstoautomaticallylocateandsizeallRAM,oritmayuseknowledgeoftheRAMinthemachine,oranyothermethodthebootloaderdesignerseesfit.)2.Initialiseoneserialport-----------------------------Existingbootloaders:OPTIONAL,RECOMMENDEDNewbootloaders:OPTIONAL,RECOMMENDEDThebootloadershouldinitialiseandenableoneserialportonthetarget.Thisallowsthekernelserialdrivertoautomaticallydetectwhichserialportitshoulduseforthekernelconsole(generallyusedfordebuggingpurposes,orcommunicationwiththetarget.)Asanalternative,thebootloadercanpasstherelevant'console='optiontothekernelviathetaggedlistsspecifingtheport,andserialformatoptionsasdescribedinlinux/Documentation/kernel-parameters.txt.3.Detectthemachinetype--------------------------Existingbootloaders:OPTIONALNewbootloaders:MANDATORYThebootloadershoulddetectthemachinetypeitsrunningonbysomemethod.Whetherthisisahardcodedvalueorsomealgorithmthatlooksattheconnectedhardwareisbeyondthescopeofthisdocument.ThebootloadermustultimatelybeabletoprovideaMACH_TYPE_xxxvaluetothekernel.(seelinux/arch/arm/tools/mach-types).4.Setupthekerneltaggedlist-------------------------------Existingbootloaders:OPTIONAL,HIGHLYRECOMMENDEDNewbootloaders:MANDATORYThebootloadermustcreateandinitialisethekerneltaggedlist.AvalidtaggedliststartswithATAG_COREandendswithATAG_NONE.TheATAG_COREtagmayormaynotbeempty.AnemptyATAG_COREtaghasthesizefieldsetto'2'(0x00000002).TheATAG_NONEmustsetthesizefieldtozero.Anynumberoftagscanbeplacedinthelist.Itisundefinedwhetherarepeatedtagappendstotheinformationcarriedbytheprevioustag,orwhetheritreplacestheinformationinitsentirety;sometagsbehaveastheformer,othersthelatter.Thebootloadermustpassataminimumthesizeandlocationofthesystemmemory,androotfilesystemlocation.Therefore,theminimumtaggedlistshouldlook:+-----------+base-|ATAG_CORE||+-----------+||ATAG_MEM||increasingaddress+-----------+||ATAG_NONE||+-----------+vThetaggedlistshouldbestoredinsystemRAM.Thetaggedlistmustbeplacedinaregionofmemorywhereneitherthekerneldecompressornorinitrd'bootp'programwilloverwriteit.Therecommendedplacementisinthefirst16KiBofRAM.5.Callingthekernelimage---------------------------Existingbootloaders:MANDATORYNewbootloaders:MANDATORYTherearetwooptionsforcallingthekernelzImage.IfthezImageisstoredinflash,andislinkedcorrectlytoberunfromflash,thenitislegalforthebootloadertocallthezImageinflashdirectly.ThezImagemayalsobeplacedinsystemRAM(atanylocation)andcalledthere.Notethatthekerneluses16KofRAMbelowtheimagetostorepagetables.Therecommendedplacementis32KiBintoRAM.Ineithercase,thefollowingconditionsmustbemet:-CPUregistersettingsr0=0,r1=machinetypenumberdiscoveredin(3)above.r2=physicaladdressoftaggedlistinsystemRAM.-CPUmodeAllformsofinterruptsmustbedisabled(IRQsandFIQs)TheCPUmustbeinSVCmode.(AspecialexceptionexistsforAngel)-Caches,MMUsTheMMUmustbeoff.Instructioncachemaybeonoroff.Datacachemustbeoff.-Thebootloaderisexpectedtocallthekernelimagebyjumpingdirectlytothefirstinstructionofthekernelimage.可以看出bootloader最少具备5项功能,上面比较清晰。可以看出,现在2.4的内核都是希望采用taggedlist的方式来进行传递的,这里没有提到比较老的方式。这里要特别注意的是,r2=physicaladdressoftaggedlistinsystemRAM.,这里的“必须”是针对于taggedlist而言的,如果采用param_struct,则并没有这个限制。这在后面将会详细分析,而这正是可能导致疑惑的地方。2、参数传递数据结构的定义位置【include/asm/setup.h】,在这里就可以看到两种参数传递方式了。可以说,现在bootloader和Linuxkernel约定的参数传递机制就是这两种,必须严格按照这两种机制进行传输,否则的话,kernel可能因为无法识别bootloader传递过来的参数而导致无法启动。关于这两种方式,在这里还有说明:/**linux/include/asm/setup.h**Copyright(C)1997-1999RussellKing**Thisprogramisfreesoftware;youcanredistributeitand/ormodify*itunderthetermsoftheGNUGeneralPublicLicenseversion2as*publishedbytheFreeSoftwareFoundation.**Structurepassedtokerneltotellitaboutthe*hardwareit'srunningon.Seelinux/Documentation/arm/Setup*formoreinfo.**NOTE:*Thisfilecontainstwoways

1 / 32
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功