版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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。每种类型的异常都有一个固定的中断向量,即入口地址。通常在这个地址存放一条跳转指令,用于挑转到异常处理程序入口处。@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@以下是固定位置存放环境变量,定义在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中没有使用 b SleepRamProc@0x34#endif#ifdefCONFIG_TEST b hmi@0x38#endif@StartVIVIhead;vivi功能子程序的开始Reset:@复位中断服务程序 @disablewatchdogtimer@关闭看门狗 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(关闭所有中断源) 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(初始化系统时钟) mov r1,#CLK_CTL_BASE@时钟控制寄存器基址0x4c000000 mvn r2,#0xff000000 str r2,[r1,#oLOCKTIME] @ldr r2,mpll_50mhz;CPU的时钟频率是50MHhz @str r2,[r1,#oMPLLCON]#ifndefCONFIG_S3C2410_MPORT1@由于该常量已定义,因此该程序代码会执行, @1:2:4CPU的频率被设置为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的时钟频率是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的时钟频率是50MHhzstrr2,[r1,#oMPLLCON]#endif bl memsetup@跳转到存储器配置子程序#ifdefCONFIG_PM @Checkifthisisawake-upfromsleep ldr r1,PMST_ADDR ldr r0,[r1] tst r0,#(PMST_SMR) bne WakeupStart#endif#ifdefCONFIG_S3C2410_SMDK@SMDK开发板使用 @AllLEDon(点亮所有的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后的语句肯定不执行,这里主要是便于程序以后的调试修改。 @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@调用串口初始化子程序#ifdefCONFIG_DEBUG_LL@调试信息 @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@调用存储器测试子程序#endif#ifdefCONFIG_S3C2410_NAND_BOOT@从NANDFlash启动 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)@内存配置子程序入下 @initializethestaticmemory @setmemorycontrolregisters mov r1,#MEM_CTL_BASE@内存控制存器基址 adrl r2,mem_cfg_val@内存控制存器数据表首地址 add r3,r1,#52@52/4=131: ldr r4,[r2],#4 str r4,[r1],#4 cmp r1,r3 bne 1b mov pc,lr@子程序返回@复制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. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 职业学院大学生创业训练基地安全责任书
- 2024年精装修水电清包工程合同书3篇
- 2024餐饮管理:食堂食材供应与运营承包合同版
- 2024餐饮服务协议:食堂运营管理条款版B版
- 2024食堂特色餐饮项目策划与执行聘用合同3篇
- 2024年跨国服务提供与许可合同
- 2024装修合同委托书范文
- 2025年度新能源汽车充电设施运营管理合同2篇
- 2024年跨境电商物流服务招投标合同
- 中医药在近视治疗中的作用
- 履约情况证明(共6篇)
- 矿井提升容器课件
- 云南省迪庆藏族自治州各县区乡镇行政村村庄村名居民村民委员会明细
- 六年级语文-文言文阅读训练题50篇-含答案
- 《洁净工程项目定额》(征求意见稿)
- 城镇燃气设计规范
- 年零售药店操作规程版
- 日有所诵(二年级)
- 搞笑个性YY娱乐频道分组设计图
- 静力触探技术标准
- 钢结构、膜结构安全技术交底
评论
0/150
提交评论