嵌入式系統(tǒng)原理與應(yīng)用 第3版 vivi-boot Vivi-S3C2410A-head.s-File_第1頁(yè)
嵌入式系統(tǒng)原理與應(yīng)用 第3版 vivi-boot Vivi-S3C2410A-head.s-File_第2頁(yè)
嵌入式系統(tǒng)原理與應(yīng)用 第3版 vivi-boot Vivi-S3C2410A-head.s-File_第3頁(yè)
嵌入式系統(tǒng)原理與應(yīng)用 第3版 vivi-boot Vivi-S3C2410A-head.s-File_第4頁(yè)
嵌入式系統(tǒng)原理與應(yīng)用 第3版 vivi-boot Vivi-S3C2410A-head.s-File_第5頁(yè)
已閱讀5頁(yè),還剩32頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

Vivi_S3C2410A_head.s_File/**vivi/arch/s3c2410/head.S:Initializehardware*Copyright(C)2001MIZIResearch,Inc.*Thisprogramisfreesoftware;youcanredistributeitand/ormodify*itunderthetermsoftheGNUGeneralPublicLicenseaspublishedby*theFreeSoftwareFoundation;eitherversion2oftheLicense,or*(atyouroption)anylaterversion.**Thisprogramisdistributedinthehopethatitwillbeuseful,*butWITHOUTANYWARRANTY;withouteventheimpliedwarrantyofMERCHANTABILITYorFITNESSFORAPARTICULARPURPOSE.SeetheGNUGeneralPublicLicenseformoredetails.**YoushouldhavereceivedacopyoftheGNUGeneralPublicLicense*alongwiththisprogram;ifnot,writetotheFreeSoftwareFoundation,Inc.,59TemplePlace,Suite330,Boston,MA02111-1307USA**Author:JanghoonLyu<nandy@>*Date:$Date:2003/02/2610:38:11$**$Revision:1.18$**History:2002-05-14:JanghoonLyu<nandy@>*-Initialcode*/#include"config.h"#include"linkage.h"#include"machine.h"@StartofexecutablecodeENTRY(_start)ENTRY(ResetEntryPoint)@以下是s3c2410CPU硬件上支持的中斷向量表,起始的物理地址是0x00000000。每種類型的異常都有一個(gè)固定的中斷向量,即入口地址。通常在這個(gè)地址存放一條跳轉(zhuǎn)指令,用于挑轉(zhuǎn)到異常處理程序入口處。@Exceptionvectortable(physicaladdress=0x00000000)b Reset@0x00:ResetUndefEntryPoint: b HandleUndef@0x04:UndefinedinstructionexceptionSWIEntryPoint: b HandleSWI@0x08:SoftwareinterruptexceptionPrefetchAbortEnteryPoint: b HandlePrefetchAbort@0x0c:PrefetchAbort(InstructionFetchMemoryAbort)DataAbortEntryPoint: b HandleDataAbort@0x10:DataAccessMemoryAbortNotUsedEntryPoint: b HandleNotUsed@0x14:NotusedIRQEntryPoint: b HandleIRQ@0x18:IRQ(InterruptRequest)exceptionFIQEntryPoint: b HandleFIQ@0x1c:FIQ(FastInterruptRequest)exception@以下是固定位置存放環(huán)境變量,定義在include/platform/smdk2410.h@VIVImagics@0x20:magicnumbersowecanverifythatweonlyput .long0@0x24: .long0@0x28:wherethisviviwaslinked,sowecanputitinmemoryintherightplace .long_start@0x2C:thiscontainstheplatform,cpuandmachineid .longARCHITECTURE_MAGIC@0x30:vivicapabilities .long0#ifdefCONFIG_PM@PM電源管理,vivi中沒(méi)有使用 b SleepRamProc@0x34#endif#ifdefCONFIG_TEST b hmi@0x38#endif@StartVIVIhead;vivi功能子程序的開(kāi)始Reset:@復(fù)位中斷服務(wù)程序 @disablewatchdogtimer@關(guān)閉看門狗 mov r1,#0x53000000@WTCON寄存器的地址為0x53000000 mov r2,#0x0 str r2,[r1]#ifdefCONFIG_S3C2410_MPORT3@配置串口0所需的控制引腳 mov r1,#0x56000000@GPACON寄存器的地址為0x56000000 mov r2,#0x00000005@GPH1=nRTS0,GPH0=nCTS0均用于UART0 str r2,[r1,#0x70]@GPHCON寄存器的地址為0x56000070 movr2,#0x00000001@GPH0禁止使用上拉電阻 str r2,[r1,#0x78]@GPHUP寄存器的地址為0x56000078 mov r2,#0x00000001@GPH1=0,GPH0=1 strr2,[r1,#0x74]@GPHDAT寄存器的地址為0x56000074#endif @disableallinterrupts(關(guān)閉所有中斷源) mov r1,#INT_CTL_BASE@中斷控制寄存器基址0x4A000000 mov r2,#0xffffffff str r2,[r1,#oINTMSK]@中斷屏蔽寄存器偏移量oINTMSK=04 ldr r2,=0x7ff str r2,[r1,#oINTSUBMSK] @子中斷屏蔽寄存器偏移量oINTSUBMSK=1c @initialisesystemclocks(初始化系統(tǒng)時(shí)鐘) mov r1,#CLK_CTL_BASE@時(shí)鐘控制寄存器基址0x4c000000 mvn r2,#0xff000000 str r2,[r1,#oLOCKTIME] @ldr r2,mpll_50mhz;CPU的時(shí)鐘頻率是50MHhz @str r2,[r1,#oMPLLCON]#ifndefCONFIG_S3C2410_MPORT1@由于該常量已定義,因此該程序代碼會(huì)執(zhí)行, @1:2:4CPU的頻率被設(shè)置為200Mhz mov r1,#CLK_CTL_BASE mov r2,#0x3 str r2,[r1,#oCLKDIVN] mrc p15,0,r1,c1,c0,0 @readctrlregister orr r1,r1,#0xc0000000 @Asynchronous mcr p15,0,r1,c1,c0,0 @writectrlregister @now,CPUclockis200Mhz mov r1,#CLK_CTL_BASE ldr r2,mpll_200mhz@CPU的時(shí)鐘頻率是50MHhz str r2,[r1,#oMPLLCON]#else @1:2:2movr1,#CLK_CTL_BASEldrr2,clock_clkdivnstrr2,[r1,#oCLKDIVN]mrcp15,0,r1,c1,c0,0@readctrlregisterorrr1,r1,#0xc0000000@Asynchronousmcrp15,0,r1,c1,c0,0@writectrlregister@now,CPUclockis100Mhzmovr1,#CLK_CTL_BASEldrr2,mpll_100mhz@CPU的時(shí)鐘頻率是50MHhzstrr2,[r1,#oMPLLCON]#endif bl memsetup@跳轉(zhuǎn)到存儲(chǔ)器配置子程序#ifdefCONFIG_PM @Checkifthisisawake-upfromsleep ldr r1,PMST_ADDR ldr r0,[r1] tst r0,#(PMST_SMR) bne WakeupStart#endif#ifdefCONFIG_S3C2410_SMDK@SMDK開(kāi)發(fā)板使用 @AllLEDon(點(diǎn)亮所有的LED顯示) mov r1,#GPIO_CTL_BASE add r1,r1,#oGPIO_F ldr r2,=0x55aa str r2,[r1,#oGPIO_CON] mov r2,#0xff str r2,[r1,#oGPIO_UP] mov r2,#0x00 str r2,[r1,#oGPIO_DAT]#endif#if0@if0后的語(yǔ)句肯定不執(zhí)行,這里主要是便于程序以后的調(diào)試修改。 @SVC mrs r0,cpsr bic r0,r0,#0xdf orr r1,r0,#0xd3 msr cpsr_all,r1#endif @setGPIOforUART(配置串口所需的I/O口引腳) mov r1,#GPIO_CTL_BASE@GPACON寄存器的地址為0x56000000 add r1,r1,#oGPIO_H ldr r2,gpio_con_uart str r2,[r1,#oGPIO_CON] ldr r2,gpio_up_uart str r2,[r1,#oGPIO_UP] bl InitUART@調(diào)用串口初始化子程序#ifdefCONFIG_DEBUG_LL@調(diào)試信息 @PrintcurrentProgramCounter ldr r1,SerBase mov r0,#'\r' bl PrintChar mov r0,#'\n' bl PrintChar mov r0,#'@' bl PrintChar mov r0,pc bl PrintHexWord#endif#ifdefCONFIG_BOOTUP_MEMTEST @simplememorytesttofindsomeDRAMflaults. bl memtest@調(diào)用存儲(chǔ)器測(cè)試子程序#endif#ifdefCONFIG_S3C2410_NAND_BOOT@從NANDFlash啟動(dòng) bl copy_myself @jumptoram ldr r1,=on_the_ram add pc,r1,#0 nop nop1: b 1b @infiniteloopon_the_ram:#endif#ifdefCONFIG_DEBUG_LL ldr r1,SerBase ldr r0,STR_STACK bl PrintWord ldr r0,DW_STACK_START bl PrintHexWord#endif @getreadtocallCfunctions ldr sp,DW_STACK_START @setupstackpointer mov fp,#0 @nopreviousframe,sofp=0 mov a2,#0 @setargvtoNULL bl main @callmain mov pc,#FLASH_BASE @otherwise,reboot@EndVIVIhead/**subroutines*/@Wake-upcodes#ifdefCONFIG_PMWakeupStart: @Clearsleepresetbit ldr r0,PMST_ADDR mov r1,#PMST_SMR str r1,[r0] @ReleasetheSDRAMsignalprotections ldr r0,PMCTL1_ADDR ldr r1,[r0] bic r1,r1,#(SCLKE|SCLK1|SCLK0) str r1,[r0] @Go... ldr r0,PMSR0_ADDR @readareturnaddress ldr r1,[r0] mov pc,r1@子程序返回 nop nop1: b 1b @infiniteloopSleepRamProc: @SDRAMisintheself-refreshmode*/ ldr r0,REFR_ADDR ldr r1,[r0] orr r1,r1,#SELF_REFRESH str r1,[r0] @waituntilSDRAMintoself-refresh mov r1,#161: subs r1,r1,#1 bne 1b @SettheSDRAMsignalprotections ldr r0,PMCTL1_ADDR ldr r1,[r0] orr r1,r1,#(SCLKE|SCLK1|SCLK0) str r1,[r0] /*Sleep...Now*/ ldr r0,PMCTL0_ADDR ldr r1,[r0] orr r1,r1,#SLEEP_ON str r1,[r0] 1: b 1b#ifdefCONFIG_TESThmi: ldr r0,PMCTL0_ADDR ldr r1,=0x7fff0 str r1,[r0] @AllLEDon mov r1,#GPIO_CTL_BASE add r1,r1,#oGPIO_F ldr r2,=0x55aa str r2,[r1,#oGPIO_CON] mov r2,#0xff str r2,[r1,#oGPIO_UP] mov r2,#0xe0 str r2,[r1,#oGPIO_DAT]1: b 1b#endif#endifENTRY(memsetup)@內(nèi)存配置子程序入下 @initializethestaticmemory @setmemorycontrolregisters mov r1,#MEM_CTL_BASE@內(nèi)存控制存器基址 adrl r2,mem_cfg_val@內(nèi)存控制存器數(shù)據(jù)表首地址 add r3,r1,#52@52/4=131: ldr r4,[r2],#4 str r4,[r1],#4 cmp r1,r3 bne 1b mov pc,lr@子程序返回@復(fù)制vivi到RAM的子程序如下:#ifdefCONFIG_S3C2410_NAND_BOOT@copy_myself:copyvivitoramcopy_myself: mov r10,lr@保存返回的PC指針@resetNAND mov r1,#NAND_CTL_BASE @ldr r2,=0xf830 @initialvalue ldr r2,=0xf973 @initialvaluebyOURS str r2,[r1,#oNFCONF] ldr r2,[r1,#oNFCONF] bic r2,r2,#0x800 @enablechip str r2,[r1,#oNFCONF] mov r2,#0xff @RESETcommand strb r2,[r1,#oNFCMD] mov r3,#0 @wait1: add r3,r3,#0x1 cmp r3,#0xa blt 1b2: ldr r2,[r1,#oNFSTAT] @waitready tst r2,#0x1 beq2b ldr r2,[r1,#oNFCONF] orr r2,r2,#0x800 @disablechip str r2,[r1,#oNFCONF]@getreadtocallCfunctions(fornand_read()) ldr sp,DW_STACK_START @setupstackpointer mov fp,#0 @nopreviousframe,sofp=0@copyvivitoRAM ldr r0,=VIVI_RAM_BASE movr1,#0x0 mov r2,#0x20000 bl nand_read_ll tst r0,#0x0 beq ok_nand_read#ifdefCONFIG_DEBUG_LLbad_nand_read: ldr r0,STR_FAIL ldr r1,SerBase bl PrintWord1: b 1b @infiniteloop#endif ok_nand_read:#ifdefCONFIG_DEBUG_LL ldr r0,STR_OK ldr r1,SerBase bl PrintWord#endif@verify mov r0,#0 ldr r1,=0x33f00000 mov r2,#0x400 @4bytes*1024=4K-bytesgo_next: ldr r3,[r0],#4 ldr r4,[r1],#4 teq r3,r4 bne notmatch subs r2,r2,#4 beq done_nand_read bne go_nextnotmatch:#ifdefCONFIG_DEBUG_LL sub r0,r0,#4 ldr r1,SerBase bl PrintHexWord ldr r0,STR_FAIL ldr r1,SerBase bl PrintWord#endif1: b 1bdone_nand_read:#ifdefCONFIG_DEBUG_LL ldr r0,STR_OK ldr r1,SerBase bl PrintWord#endif mov pc,r10@clearmemory@r0:startaddress@r1:lengthmem_clear: mov r2,#0 mov r3,r2 mov r4,r2 mov r5,r2 mov r6,r2 mov r7,r2 mov r8,r2 mov r9,r2clear_loop: stmia r0!,{r2-r9} subs r1,r1,#(8*4) bne clear_loop mov pc,lr@子程序返回#endif@CONFIG_S3C2410_NAND_BOOT#ifdefCONFIG_BOOTUP_MEMTEST@Simplememorytestfunctionmemtest: mov r10,lr#ifdefCONFIG_DEBUG_LL mov r0,#'M' ldr r1,SerBase bl PrintChar mov r0,#'T' ldr r1,SerBase bl PrintChar mov r0,#'S' ldr r1,SerBase bl PrintChar mov r0,#'T' ldr r1,SerBase bl PrintChar mov r0,#'' ldr r1,SerBase bl PrintChar#endif/*checkthefirst1MBinincrementsof4k*/movr7,#0x1000movr6,r7,lsl#8/*4k<<2^8=1MB*/movr5,#DRAM_BASEmem_test_loop:movr0,r5bltestram_nostackteqr0,#1beqbadramaddr5,r5,r7subsr6,r6,r7bnemem_test_loop@thefirstmegabyteisOK.soletusclearit.movr0,#((1024*1024)/(8*4)) @1MBinstepsof32bytesmovr1,#DRAM_BASEmovr2,#0movr3,#0movr4,#0movr5,#0movr6,#0movr7,#0movr8,#0movr9,#0clear_loop_memtest:stmiar1!,{r2-r9}subsr0,r0,#(8*4)bneclear_loop_memtest#ifdefCONFIG_DEBUG_LL ldr r0,STR_OK ldr r1,SerBase bl PrintWord#endif mov pc,r10 @returnbadram:#ifdefCONFIG_DEBUG_LL ldr r0,STR_FAIL ldr r1,SerBase bl PrintWord#endif1: b 1b @loop@testmem.S:memorytester,testifthereisRAMavailableatgivenlocation@Copyright(C)2001RussellKing(rmk@.uk)@Thisversionclobbersregistersr1-r4,sobesuretostoretheircontents@inasafeposition.ThisfunctionisnotAPCScompliant,soonlyuseit@fromassemblycode.@r0=addresstotest@returnsr0=0-rampresent,r0=1-noram@clobbersr1-r4ENTRY(testram_nostack)ldmiar0,{r1,r2}@storecurrentvalueinr1andr2movr3,#0x55@write0x55tofirstwordmovr4,#0xaa@0xaatosecondstmiar0,{r3,r4}ldmiar0,{r3,r4}@readitbackteqr3,#0x55@dothevaluesmatchteqeqr4,#0xaabnebad@oops,nomovr3,#0xaa@write0xaatofirstwordmovr4,#0x55@0x55tosecondstmiar0,{r3,r4}ldmiar0,{r3,r4}@readitbackteqr3,#0xaa@dothevaluesmatchteqeqr4,#0x55bad:stmiar0,{r1,r2}@inanycase,restoreolddatamoveqr0,#0@ok-allvaluesmatchedmovner0,#1@noramatthislocationmovpc,lr@子程序返回#endif@CONFIG_BOOTUP_MEMTEST@InitializeUART@r0=numberofUARTportInitUART: ldr r1,SerBase mov r2,#0x0 str r2,[r1,#oUFCON] str r2,[r1,#oUMCON] mov r2,#0x3 str r2,[r1,#oULCON] ldr r2,=0x245 str r2,[r1,#oUCON]#defineUART_BRD((50000000/(UART_BAUD_RATE*16))-1) mov r2,#UART_BRD str r2,[r1,#oUBRDIV] mov r3,#100 mov r2,#0x01: sub r3,r3,#0x1 tst r2,r3 bne 1b#if0 mov r2,#'U' str r2,[r1,#oUTXHL]1: ldr r3,[r1,#oUTRSTAT] and r3,r3,#UTRSTAT_TX_EMPTY tst r3,#UTRSTAT_TX_EMPTY bne 1b mov r2,#'0' str r2,[r1,#oUTXHL]1: ldr r3,[r1,#oUTRSTAT] and r3,r3,#UTRSTAT_TX_EMPTY tst r3,#UTRSTAT_TX_EMPTY bne 1b #endif mov pc,lr@子程序返回@ExceptionhandlingfunctionsHandleUndef:#ifdefCONFIG_DEBUG_LL mov r12,r14 ldr r0,STR_UNDEF ldr r1,SerBase bl PrintWord bl PrintFaultAddr#endif1: b 1b @infiniteloopHandleSWI:#ifdefCONFIG_DEBUG_LL mov r12,r14 ldr r0,STR_SWI ldr r1,SerBase bl PrintWord bl PrintFaultAddr#endif1: b 1b @infiniteloopHandlePrefetchAbort:#ifdefCONFIG_DEBUG_LL mov r12,r14 ldr r0,STR_PREFETCH_ABORT ldr r1,SerBase bl PrintWord bl PrintFaultAddr#endif1: b 1b @infiniteloopHandleDataAbort:#ifdefCONFIG_DEBUG_LL mov r12,r14 ldr r0,STR_DATA_ABORT ldr r1,SerBase bl PrintWord bl PrintFaultAddr#endif1: b 1b @infiniteloopHandleIRQ:#ifdefCONFIG_DEBUG_LL mov r12,r14 ldr r0,STR_IRQ ldr r1,SerBase bl PrintWord bl PrintFaultAddr#endif1: b 1b @infiniteloopHandleFIQ:#ifdefCONFIG_DEBUG_LL mov r12,r14 ldr r0,STR_FIQ ldr r1,SerBase bl PrintWord bl PrintFaultAddr#endif1: b 1b @infiniteloopHandleNotUsed:#ifdefCONFIG_DEBUG_LL mov r12,r14 ldr r0,STR_NOT_USED ldr r1,SerBase bl PrintWord bl PrintFaultAddr#endif1: b 1b @infiniteloop@LowLevelDebug#ifdefCONFIG_DEBUG_LL@PrintFaultAddr:Printfalutaddress@r12:containsaddressofinstruction+4PrintFaultAddr: mov r0,r12 @Printaddressofinstruction+4 ldr r1,SerBase bl PrintHexWord mrc p15,0,r0,c6,c0,0 @Readfaultvirtualaddress ldr r1,SerBase bl PrintHexWord mov pc,lr@子程序返回@PrintHexNibble:printstheleast-significantnibbleinR0asa@hexdigit@r0containsnibbletowriteasHex@r1containsbaseofserialport@writesrowithXXX,modifiesr0,r1,r2@TODO:writerowithXXXregtoerrorhandling@FallsthroughtoPrintCharPrintHexNibble: adr r2,HEX_TO_ASCII_TABLE and r0,r0,#0xF ldr r0,[r2,r0] @converttoascii b PrintChar@PrintChar:printsthecharacterinR0@r0containsthecharacter@r1containsbaseofserialport@writesrowithXXX,modifiesr0,r1,r2@TODO:writerowithXXXregtoerrorhandlingPrintChar:TXBusy: ldr r2,[r1,#oUTRSTAT] and r2,r2,#UTRSTAT_TX_EMPTY tst r2,#UTRSTAT_TX_EMPTY beq TXBusy str r0,[r1,#oUTXHL] mov pc,lr@PrintWord:printsthe4charactersinR0@r0containsthebinaryword@r1containsthebaseoftheserialport@writesrowithXXX,modifiesr0,r1,r2@TODO:writerowithXXXregtoerrorhandlingPrintWord: mov r3,r0 mov r4,lr bl PrintChar mov r0,r3,LSR#8 /*shiftwordright8bits*/ bl PrintChar mov r0,r3,LSR#16 /*shiftwordright16bits*/ bl PrintChar mov r0,r3,LSR#24 /*shiftwordright24bits*/ bl PrintChar mov r0,#'\r' bl PrintChar mov r0,#'\n' bl PrintChar mov pc,r4@PrintHexWord:printsthe4bytesinR0as8hexasciicharacters@followedbyanewline@r0containsthebinaryword@r1containsthebaseoftheserialport@writesrowithXXX,modifiesr0,r1,r2@TODO:writerowithXXXregtoerrorhandlingPrintHexWord: mov r4,lr mov r3,r0 mov r0,r3,LSR#28 bl PrintHexNibble mov r0,r3,LSR#24 bl PrintHexNibble mov r0,r3,LSR#20 bl PrintHexNibble mov r0,r3,LSR#16 bl PrintHexNibble mov r0,r3,LSR#12 bl PrintHexNibble mov

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論