




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
第第頁ARM協(xié)處理器指令A(yù)RM微處理器可支持多達(dá)16個(gè)協(xié)處理器,用于各種協(xié)處理操作,在程序執(zhí)行的過程中,每個(gè)協(xié)處理器只執(zhí)行針對(duì)自身的協(xié)處理指令,忽略ARM處理器和其他協(xié)處理器的指令。ARM的協(xié)處理器指令主要用于ARM處理器初始化ARM協(xié)處理器的數(shù)據(jù)處理操作,以及在ARM處理器的寄存器和協(xié)處理器的寄存器之間傳送數(shù)據(jù),和在ARM協(xié)處理器的寄存器和存儲(chǔ)器之間傳送數(shù)據(jù)。ARM協(xié)處理器指令包括以下5條:
CDP協(xié)處理器數(shù)操作指令LDC協(xié)處理器數(shù)據(jù)加載指令STC協(xié)處理器數(shù)據(jù)存儲(chǔ)指令MCRARM處理器寄存器到協(xié)處理器寄存器的數(shù)據(jù)傳送指令MRC協(xié)處理器寄存器到ARM處理器寄存器的數(shù)據(jù)傳送指令
CP15系統(tǒng)控制協(xié)處理器
CP15—系統(tǒng)控制協(xié)處理器(thesystemcontrolcoprocessor)他通過協(xié)處理器指令MCR和MRC提供具體的寄存器來配置和控制caches、MMU、保護(hù)系統(tǒng)、配置時(shí)鐘模式(在bootloader時(shí)鐘初始化用到)
CP15的寄存器只能被MRC和MCR(MovetoCoprocessorfromARMRegister)指令訪問一些要說明的內(nèi)容,摘錄見下::
Co-processorsTherearebetweenzeroandthreepossibleco-processors.MostdesktopARMsystemsdonothavelogicforexternalco-processors,sowemayeitherusethatwhichisbuiltintotheARMitself,oranemulatedco-processor.CP15isreservedontheARM3andlaterprocessorsforinternalconfiguration,asdescribedinthisdocument.CP0andCP1isusedbythefloatingpointsystem.Itmayeitherbeanexternalfloatingpointchip(asusedwiththeARM3),hardwarebuiltintotheprocessor(asintheARM7500FE),oratotallysoftware-basedemulation(aswiththeFPEmulatorthatweallknow).Hereisashortexerciseforyou:
10DIMcode%1620P%=code%30[OPT340CDPCP1,0,C0,C1,C2,050ADFSF0,F1,F360MOVPC,R1470]>RUN00008F78OPT300008F78EE010102CDPCP1,0,C0,C1,C200008F7CEE010102ADFSF0,F1,F200008F80E1A0F00EMOVPC,R14>Whatdoyounotice?:-)
WhentheARMexecutesaco-processorinstruction,oranundefinedinstruction,itwillofferittoanyco-processorswhichmaybepresentlyattached.Ifhardwareisavailabletoprocessthegiveninstruction,thenitisexpectedtodoso.Ifitisbusyatthetimetheinstructionisoffered,theARMwillwaitforit.Ifthereisnoco-processorcapableofexecutingtheinstruction,theARMwilltakeitsundefinedinstructiontrap,inwhichcasethefollowingwillhappen:
ThePSRandPCarebothsaved(themethoddiffersfor26bitand32bitARMs)SVCmode(26bit)/UNDmode(32bit)isentered,andtheIbitofthePSRissetTheinstructionataddresstfitted.TheFloatingPointEmulatorworksbydoingthis.Toreturn,simplypullthesavedPCandPSR(dependson26/32bit)andpushthemtothecurrentPCandPSR,likeMOVSPC,R14in26bitsystems.Thiswillpickupwiththeinstructionfollowingtheonewhichcausedthetrap.
Alloftheco-processorinstructionscanbeexecutedconditionally.PleasenotethattheconditionalsrelatetothestatusoftheARMprocessor,andnotthestatusofanyoftheco-processors.ThisisbecausetheARMalwaystriestheinstructionfirst,andoffersitaroundandmaybetakestheundefinedapplicationtrap,sotheconditionsareARMrelated.Tomakethisclearer:
10DIMcode%3220P%=code%30[OPT340FLTSF0,R050FLTSF1,R160FMLSF2,F0,F170FIXR0,F280MOVSPC,R1490]100INPUT"Firstnumber:"A%110INPUT"Secondnumber:"B%120PRINTUSR(code%)ThisprobablywontassemblewithoutanenhancedBASICassembler.Anyway,youmightthinktheARMwillhandovertothefloatingpointco-processortodothefourFPinstructions,thenhandbackafterwards.Ifyoudid,youwouldbeincorrect!
Whatactuallyisexecutedis:
MCRCP1,0,R0,C0,C0MCRCP1,0,R1,C1,C0CDPCP1,9,C2,C0,C1MRCCP1,0,R0,C0,C2Itisworthpointingoutthatobjasmspecifiesco-processorregistersusingtheCRnotation(ie,CR0-CR15),whichisfirstdefinedwiththeCNdirective.Itdoesnotappearasifdefaultco-processorinstructionsaredefinedinNickRobertsASM,thoughIveonlylookedintheinstructionsatthe"definedsymbols"section...DarrenSaltsExtBASICasmprovidestheregisternamesC0-C15torefertotheco-processors.Soifanyoftheseexamplesfailwhenyoutrytoassemblethem,pleasecheckwhatformatyourassemblerprovidestheseinstructions.
MRCTheinstructionMRCtransfersaco-processorregistertoanARMregister.Ittakestheform:MRCmaybeomitted,asitisintheexample,buttheotherpartsoftheMRCinstructionmustbesupplied.
MCRTheinstructionMCRtransfersanARMregistertoaco-processorregister.Ittakestheform:MCR,,,,,Theco-processorisfreetointerpretthefieldsasitdesires,butthestandardinterpretationisthatthecontentsoftheARMregisterarewrittentotheco-processorregisterusingtheoperationcodegiven,whichmaybefurthermodifiedbythesecondco-processorregisterand/orthesecondoperationcode.
在U-Boot中我們用到了c7和c8這兩個(gè)協(xié)處理器,再來看看MCR的詳細(xì)用法:
MCR指令:
MCR指令將ARM處理器的寄存器中的數(shù)據(jù)傳送到協(xié)處理器寄存器中。如果協(xié)處理器不能成功地執(zhí)行該操作,將產(chǎn)生未定義的指令異常中斷。
指令語法格式:
MCR{},,,,{,}
MCR{}p15,0,,,{,}
其中
指令執(zhí)行的條件碼.當(dāng)忽略時(shí)指令為無條件執(zhí)行。
協(xié)處理器將執(zhí)行的操作的操作碼。對(duì)于CP15協(xié)處理器來說,永遠(yuǎn)為0b000,當(dāng)不為0b000時(shí),該指令操作結(jié)果不可預(yù)知。
作為源寄存器的ARM寄存器,其值將被傳送到協(xié)處理器寄存器中
作為目標(biāo)寄存器的協(xié)處理器寄存器,其編號(hào)可能是C0,C1,…,C15。
和兩者組合決定對(duì)協(xié)處理器寄存器進(jìn)行所需要的操作,如果沒有指定,則將為為C0,opcode_2為0
mcrp15,0,r0,c7,c7,0/*flushv3/v4cache*/
可以看出,其中
rd為r0=0
CRn為C7
CRm為C7
對(duì)于這行代碼的作用,以此按照語法,來一點(diǎn)點(diǎn)解釋如下:
首先,mcr做的事情,其實(shí)很簡單,就是“ARM處理器的寄存器中的數(shù)據(jù)傳送到協(xié)處理器寄存器中”,
此處即是,將ARM的寄存器r0中的數(shù)據(jù),此時(shí)r0=0,所以就是把0這個(gè)數(shù)據(jù),傳送到協(xié)處理器CP15中。
而對(duì)應(yīng)就是寫入到“”這個(gè)“目標(biāo)寄存器的協(xié)處理器寄存器”,此處CRn為C7,即將0寫入到寄存器7(Register7)中去。
而上面關(guān)于Register7的含義中也說了,“Anydatawrittentothislocationwillcausetheselectedcachetobeflushed”,即你往這個(gè)寄存器7中寫入任何數(shù)據(jù),都會(huì)導(dǎo)致對(duì)應(yīng)的緩存被清空。而到底那個(gè)緩存被清空呢,即我們這行指令
mcrp15,0,r0,c7,c7,0
起了什么作用呢
那是由“和兩者組合決定”的。
而此處CRm為C7,opcode_2為0,而對(duì)于C7和0的組合的作用,參見上面的那個(gè)表中Register7中的FlashI+D那一行,
當(dāng)opcode_2為0,CRm為0111=7,就是我們要找的,其作用是“FlushI+D”,即清空指令緩存ICache和數(shù)據(jù)緩存DCache。
根據(jù)該表,同理,如果是opcode_2=0,而CRm=0101b=5,那么對(duì)應(yīng)的就是去“FlushI”,即只清除指令緩存ICache了。
而對(duì)應(yīng)的指令也就是
mcrp15,0,r0,c7,c5,0
此解釋說此行代碼的作用是,清理v3或v4的緩存
其中v4,我們很好理解,因?yàn)槲覀兇颂幍腃PU是ARM920T的核心,是屬于ARMV4的,而為何又說,也可以清除v3的cache呢?
那是因?yàn)椋旧磉@些寄存器位域的定義,都是向下兼容的,參見上面引用的內(nèi)容,也寫到了:
ARM710
Register7-IDCflush(writeonly)AnydatawrittentothislocationwillcausetheIDC(Instruction/Datacache)tobeflushed.
即,對(duì)于ARM7的話,你寫同樣的這行代碼
mcrp15,0,r0,c7,c7,0
也還是向register7中寫入了數(shù)據(jù)0,這也同樣滿足了其所說的“Anydatawrittentothislocati
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 玉米根茬挖掘裝置及關(guān)鍵部件設(shè)計(jì)與試驗(yàn)研究
- 辦公檔案柜合同范例
- 磁飽和式可控電抗器振動(dòng)噪聲與其鐵心飽和程度的關(guān)系研究
- 濾池式微生物電化學(xué)反應(yīng)器對(duì)畜禽廢水的深度處理研究
- 企業(yè)合作合同范例范例
- 關(guān)于文化演出安全合同范例
- 產(chǎn)床購銷合同范例
- 個(gè)人安全協(xié)議合同范例
- 辦理房屋合同范本
- 養(yǎng)魚收購合同范本
- 采購管理實(shí)務(wù)全套教學(xué)課件
- 貴州區(qū)域地質(zhì)地史概述
- Aptitude態(tài)度的重要性
- 《推薦》500kV輸電線路應(yīng)急處置預(yù)案6個(gè)
- 麗聲北極星分級(jí)繪本第三級(jí)下 The Class Trip 課件
- 第一課想聽聽我的忠告嗎
- 高英Lesson3 Pub Talk and the King27s English
- 防洪堤防工程堤頂高程的計(jì)算表
- 古詩詞常見題材之思鄉(xiāng)懷人詩鑒賞
- 《平方差公式(1)》導(dǎo)學(xué)案
- 等保三級(jí)基線要求判分標(biāo)準(zhǔn)v10
評(píng)論
0/150
提交評(píng)論