⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cstartup.s

📁 开发三星s3c44b0引导程序
💻 S
字号:
;/**********************************************************************/
;/*                                                                    */
;/*   MODULE:      UADSLMCU/KS8947/rombegin.s                          */
;/*   PURPOSE:     Startup Code for ROM Based applications.            */
;/*   Description: S5N8947 BSP ver.1.0.                                */
;/*                                                                    */
;/*--------------------------------------------------------------------*/
;/*              COPYRIGHT 2001 SAMSUNG ELECTRONICS.                   */
;/*--------------------------------------------------------------------*/
;/*                                                                    */
;/*                                                                    */
;/**********************************************************************/

;/**********************************************************************/
;/*                                                                    */ 
;/*       Copyright (c) 2003 上海量子光电公司                          */
;/*                                                                    */
;/*                                                                    */
;/**********************************************************************/
        
        GET     board.inc

        IMPORT  RomHdwInit
        IMPORT  SetVector

;       IMPORT  UNDEFWrapper
;       IMPORT  PREFETCHWrapper
;       IMPORT  ABORTWrapper
;       IMPORT  RESERVEDWrapper
;       IMPORT  IRQWrapper
;       IMPORT  FIQWrapper
;       IMPORT  SWIWrapper

        EXPORT  SysInitVars


;************************************************************************
;* Entry point of RAM based project.                                    *
;************************************************************************
        AREA    ROMBEGIN,   CODE,   READONLY


        ENTRY

;************************************************************************
; __main: Pseudo C entry point
;
; The C compiler genereates a reference to the symbol "__main" to ensure
; that the object module containing the entry point gets pulled in.
;
; This entry point is never actually called.
;************************************************************************
		EXPORT  __main
__main
;************************************************************************
; First instruction to be executed.
;
; Branch to the HdwInit entry point in the BSP.
;
; Note: We must use LDR pc, =HdwInit instruction not just B HdwInit.
;       This is because, on RESET we are executing in ROM at location 0.
;       The first thing HdwInit will do is to unmap the ROM at location
;       0 and map RAM in its place. If we use a B HdwInit we will still
;       be executing from the ROM at location 0. The LDR pc, =HdwInit
;       ensures we are executing in the ROM copy located in high memory.
;       It is then safe to map out the ROM at location 0.
;
; Following the RESET branch are branches for all the remaining vectors.
; On a development board these will not be used since the ROM will
; be remapped away from location 0. However a real target might run
; with ROM always mapped to location 0, in which case we need to have
; branches at the vector locations.
;************************************************************************
;        LDR     pc, =RomHdwInit             ; Reset vector
;        LDR     pc, =Undefined_Handler      ; Undefined instruction
;        LDR     pc, =SWI_Handler            ; SWI
;        LDR     pc, =Prefetch_Handler       ; Prefetch abort
;        LDR     pc, =Abort_Handler          ; Data abort
;        LDR     pc, =RomHdwInit             ; Address exception
;        LDR     pc, =IRQ_Handler            ; IRQ
;        LDR     pc, =FIQ_Handler            ; FIQ

		EXPORT _start
_start
		B 		RomHdwInit
		B		Undefined_Handler
		B		SWI_Handler
		B		Prefetch_Handler
		B		Abort_Handler
		B		RomHdwInit
		B		IRQ_Handler
		B		FIQ_Handler

;==========================================================
; The Default Exception Handler Vector Entry Pointer Setup
;==========================================================
FIQ_Handler
        SUB     sp, sp, #4
        STMFD   sp!,{r0}
        LDR     r0, =HandleFiq
        LDR     r0, [r0]
        STR     r0, [sp, #4]
        LDMFD   sp!,{r0, pc}

IRQ_Handler
        SUB     sp, sp, #4
        STMFD   sp!,{r0}
        LDR     r0, =HandleIrq
        LDR     r0, [r0]
        STR     r0, [sp, #4]
        LDMFD   sp!,{r0, pc}

Prefetch_Handler
        SUB     sp, sp, #4
        STMFD   sp!,{r0}
        LDR     r0, =HandlePrefetch
        LDR     r0, [r0]
        STR     r0, [sp, #4]
        LDMFD   sp!,{r0, pc}

Abort_Handler
        SUB     sp, sp, #4
        STMFD   sp!,{r0}
        LDR     r0, =HandleAbort
        LDR     r0, [r0]
        STR     r0, [sp, #4]
        LDMFD   sp!,{r0, pc}

Undefined_Handler
        SUB     sp, sp, #4
        STMFD   sp!,{r0}
        LDR     r0, =HandleUndef
        LDR     r0, [r0]
        STR     r0, [sp, #4]
        LDMFD   sp!,{r0, pc}

SWI_Handler
        SUB     sp, sp, #4
        STMFD   sp!, {r0}
        LDR     r0, =HandleSwi
        LDR     r0, [r0]
        STR     r0, [sp, #4]
        LDMFD   sp!, {r0, pc}




;************************************************************************
; The linker defines the following symbols which allow us to locate
; the various sections (CODE, DATA, BSS) within the image.
;
;                          ROM Image
;                          +-----------------+
; Image$$RO$$Base       -> | CODE            |
;                          | ...             |
;                          +-----------------+ <- Image$$RO$$Limit
;                          | Initialising    |
;                          | data ....       |
;                          +-----------------+
;
;                          RAM Image
;                          +-----------------+
; Image$$RW$$Base       -> | Initialised     |
;                          | data            |
; Image$$ZI$$Base       -> +-----------------+ <- Image$$RW$$Limit
;                          | Zero init (BSS) |
;                          | data            |
;                          +-----------------+ <- Image$$ZI$$Limit
;
; Note that all xxx$$Limit variables point to the final byte + 1, not
; the final byte so xxx$$Limit - xxx$$Base gives the size of the section.
;
;************************************************************************
        IMPORT  |Image$$ZI$$Base|
        IMPORT  |Image$$ZI$$Limit|
        IMPORT  |Image$$RO$$Limit|
        IMPORT  |Image$$RW$$Base|
;
;************************************************************************
; SysInitVars: Initialise the DATA and BSS sections.
;
; The DATA section is initialised by copying data from the end of the
; ROM image (given by Image$$RO$$Limit) to the start of the RAM image
; (given by Image$$RW$$Base), stopping when we reach Image$$RW$$Limit.
;
; All data from Image$$RW$$Limit to Image$$ZI$$Limit is then cleared to 0
;************************************************************************
SysInitVars
;------------------------------------------------------------------------
; Load up the linker defined values for the static data copy
;------------------------------------------------------------------------
       LDR     r0, =|Image$$RO$$Limit|
        LDR     r1, =|Image$$RW$$Base|
        LDR     r3, =|Image$$ZI$$Base|

;------------------------------------------------------------------------
; But first check whether we are trying to copy to the same address.
; If so, this means that the image was linked as an application image
; with the DATA section immediately following the CODE section. Therefore
; there is nothing to copy since the data is already in place.
;------------------------------------------------------------------------
        CMP     r0, r1
        BEQ     %1

;------------------------------------------------------------------------
; Stop on CS (ie R1 becomes >= R3). Carry has the same sense as 6502
; (ie Carry = NOT Borrow).
;------------------------------------------------------------------------
0       CMP     r1, r3
        LDRCC   r2, [r0], #4
        STRCC   r2, [r1], #4
        BCC     %0
;
;------------------------------------------------------------------------
; Clear remainder of data to Image$$ZI$$Limit to 0
;------------------------------------------------------------------------
1       LDR     r1, =|Image$$ZI$$Limit|
        MOV     r2, #0
2       CMP     r3, r1
        STRCC   r2, [r3], #4
        BCC     %2
        MOV     pc, lr

;------------------------------------------------------------------------

CInitData
 		IMPORT      |Image$$RO$$Limit|      ; End of ROM code (=start of ROM data)
		IMPORT      |Image$$RW$$Base|       ; Base of RAM to initialise
		IMPORT      |Image$$ZI$$Base|       ; Base and limit of area
		IMPORT      |Image$$ZI$$Limit|      ; Top of zero init segment
	
		DCD     |Image$$RO$$Limit|      ; End of ROM code (=start of ROM data)
 		DCD     |Image$$RW$$Base|       ; Base of RAM to initialise
 		DCD     |Image$$ZI$$Base|       ; Base and limit of area
 		DCD     |Image$$ZI$$Limit|      ; Top of zero init segment
 		DCD		_start
EndInitC   

		;EXPORT reset_cpu
		EXPORT S5N8947_SetMemoryLimit

;reset_cpu
		;mov r0,#0
		;mov pc,lr
	
	
S5N8947_SetMemoryLimit
		stmfd   r13!,{r3-r8,r14}
		add     r8, pc,#-(8+.-CInitData)  ; @ where to read values (relative)
		ldmia   r8, {r3, r4, r5, r6, r7}
	
		sub		r5, r5, r4
		add		r3, r3, r5
		str		r3,[r1]
		str		r6,[r2]
		str		r7,[r0]
		ldmfd   r13!,{r2-r7,r14}
		mov pc,lr     

        END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -