您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 项目/工程管理 > pmon启动分析(汇编部分)
/*$Id:start.S,v1.1.1.12006/09/1401:59:08rootExp$*//**Copyright(c)2001OpsyconAB()**Redistributionanduseinsourceandbinaryforms,withorwithout*modification,arepermittedprovidedthatthefollowingconditions*aremet:*1.Redistributionsofsourcecodemustretaintheabovecopyright*notice,thislistofconditionsandthefollowingdisclaimer.*2.Redistributionsinbinaryformmustreproducetheabovecopyright*notice,thislistofconditionsandthefollowingdisclaimerinthe*documentationand/orothermaterialsprovidedwiththedistribution.*3.Alladvertisingmaterialsmentioningfeaturesoruseofthissoftware*mustdisplaythefollowingacknowledgement:*ThisproductincludessoftwaredevelopedbyOpsyconAB,Sweden.*4.Thenameoftheauthormaynotbeusedtoendorseorpromoteproducts*derivedfromthissoftwarewithoutspecificpriorwrittenpermission.**THISSOFTWAREISPROVIDEDBYTHEAUTHOR``ASIS''ANDANYEXPRESS*ORIMPLIEDWARRANTIES,INCLUDING,BUTNOTLIMITEDTO,THEIMPLIED*WARRANTIESOFMERCHANTABILITYANDFITNESSFORAPARTICULARPURPOSE*AREDISCLAIMED.INNOEVENTSHALLTHEAUTHORBELIABLEFORANY*DIRECT,INDIRECT,INCIDENTAL,SPECIAL,EXEMPLARY,ORCONSEQUENTIAL*DAMAGES(INCLUDING,BUTNOTLIMITEDTO,PROCUREMENTOFSUBSTITUTEGOODS*ORSERVICES;LOSSOFUSE,DATA,ORPROFITS;ORBUSINESSINTERRUPTION)*HOWEVERCAUSEDANDONANYTHEORYOFLIABILITY,WHETHERINCONTRACT,STRICT*LIABILITY,ORTORT(INCLUDINGNEGLIGENCEOROTHERWISE)ARISINGINANYWAY*OUTOFTHEUSEOFTHISSOFTWARE,EVENIFADVISEDOFTHEPOSSIBILITYOF*SUCHDAMAGE.**/#ifndef_KERNEL#define_KERNEL#endif#includeasm.h#includeregnum.h#includecpu.h#includepte.h#includepmon/dev/ns16550.h#includetarget/prid.h#includetarget/sbd.h#includetarget/fcr.h#includetarget/via686b.h#includetarget/i8254.h#includetarget/isapnpreg.h#defineDEBUG_LOCORE#ifndefBOOT_FROM_EJTAG#defineBOOT_FROM_EJTAG#endif#undefBOOT_FROM_EJTAG#ifdefDEBUG_LOCORE#defineTTYDBG(x)\.rdata;98:.ascizx;.text;laa0,98b;balstringserial;nop#else#defineTTYDBG(x)#endif#definePRINTSTR(x)\.rdata;98:.ascizx;.text;laa0,98b;balstringserial;nop/*Delaymacro*/#defineDELAY(count)\liv0,count;\99:\bnezv0,99b;\addiuv0,-1#definetmpsizes1#definemsizes2#definebonitos4#definedbgs5#definesdCfgs6#defineCP0_CONFIG$16#defineCP0_TAGLO$28#defineCP0_TAGHI$29/**Registerusage:**s0linkversusloadoffset,usedtorelocateabsoluteadresses.*s1free*s2memorysize.*s3free.*s4Bonitobaseaddress.*s5dbg.*s6sdCfg.*s7rasave.*s8L3Cachesize.*/.setnoreorder.globl_start.globlstart.globl__main_start:start:.globlstack/*栈的大小是16K,从反汇编的地址可以看出,在下面lasp,stack中堆栈指针SP指向的地址是0x8000C000,可以看出sp的指向的位置,并不是指向flash,因此开始的堆栈用的就是sdram,而ld生成代码的text段的起始地址为0x80010000,这是吻合的。*/stack=start-0x4000/*PlacePMONstackbelowPMONstartinRAM*//*NOTE!!Notmorethat16instructionshere!!!Rightnowit'sFULL!*/mtc0zero,COP_0_STATUS_REG/*禁止中断*/mtc0zero,COP_0_CAUSE_REG/*禁止异常处理*/lit0,SR_BOOT_EXC_VEC/*ExceptiontoBoostrapLocation*/mtc0t0,COP_0_STATUS_REG/*以上两句中SR_BOOT_EXC_VEC的值是0x00400000,其目的就是设置协处理器0的状态寄存器status的BEV位为1,使得CPU使用ROM(kseg1空间的异常入口),可见此时的这些代码都是在ROM中运行的。*/lasp,stacklagp,_gp//baluncached/*Switchtouncachedaddressspace*/nopballocate/*Getcurrentexecuteaddress*/nopuncached:orra,UNCACHED_MEMORY_ADDRjranop/*ballocate是一条跳转指令。先说说bal这条指令。通常bal指令会算出相对于PC寄存器的偏移量,然后把PC+8指令的地址放到ra寄存器里,也就是把uncached:即把orra,UNCACHED_MEMORY_ADDR这条指令的地址放到ra寄存器中。由于龙芯加电启动时是从0xBFC00000地址开始的,那么此时ra寄存器中的值就是0xBFC0002C,此后程序就跳转到locate这里开始执行。*//*由于龙芯的地址空间决定,当BEV=1时,异常入口地址从0xBFC00200出开始,所以这里的代码不能太长,指令条数是有限的,但并不是上面说的16条(这是我的理解),因为后面紧跟着是其它中断向量的地址。*//**Rebootvectorusablefromoutsidepmon.*//*以下是各种异常*/.align9ext_map_and_reboot:lia0,0x10000000/*testfrom0xbfcxxxxxor0xff20xxxx*/anda0,rabneza0,1flaa0,_startlis0,0xbfc00000subus0,a01:laa0,v200_msgbalstringserialnopbexc_common.align7/*bfc00280*/laa0,v280_msgbalstringserialnopbexc_common/*Cacheerror*/.align8/*bfc00300*/PRINTSTR(\r\nPANIC!UnexpectedCacheErrorexception!)mfc0a0,COP_0_CACHE_ERRbalhexserialnopbexc_common/*Generalexception*/.align7/*bfc00380*/lia0,0x10000000/*testfrom0xbfcxxxxxor0xff20xxxx*/anda0,rabneza0,1flaa0,_startlis0,0xbfc00000subus0,a01:laa0,v380_msgbalstringserialnopbexc_common.align9/*bfc00400*/laa0,v400_msgbalstringserialnopbexc_common.align7/*bfc00480*/#laa0,v480_msg#balstringserial#nop#bexc_common#if0lis0,(0xbfc00000-0x81000000)PRINTSTR(ACPI_MEM_CEHCK=)lia1,0lit0,0xa0000000lit2,0xa01000001:lwt1,(t0)addua1,a1,t1addiut0,t0,4bnet0,t2,1bnopaddua0,a1,zerobalhexserialnopPRINTSTR(\r\n)#endif/*acpi:setddrautorefreshandsuspend*/lit0,0xaffffe30lwt1,0x4(t0)lit2,0x1ort1,t1,t2swt1,0x4(t0)lit0,0xbfe7c008lwt1,0x0(t0)orit1,t1,0x2000swt1,0x0(t0).align8/*bfc00500*/exc_common:PRINTSTR(\r\nCAUSE=)mfc0a0,COP_0_CAUSE_REGbalhexserialnopPRINTSTR(\r\nSTATUS=)mfc0a0,COP_0_STATUS_REGbalhexserialnopPRINTSTR(\r\nERRORPC=)mfc0a0,COP_0_ERROR_PCbalhexserialnopPRINTSTR(\r\nEPC=)mfc0a0,COP_0_EXC_PCbalhexserialnopPRINTSTR(\r\nBADADDR=)mfc0a0,COP_0_BAD_VADDRbalhexserialnopbalmydebug_mainnop1:b1bnop.align9nop.align8.wordread.wordwrite.wordopen.wordclose.wordnullfunction.wordprintf.wordvsprintf.wordnullfunction.wordnullfunction.wordgetenv.wordnullfunction.wordnullfunction.wordnullfunction.wordnullfunction/*这里是例外向量,其实什么都没做,就是输出一些相关的信息,然后统一跳转到ex_common处来处理,这是靠对
本文标题:pmon启动分析(汇编部分)
链接地址:https://www.777doc.com/doc-4767844 .html