?? copyalgo.asm
字號(hào):
;--------------------------------------------------------------------------------------------------
; Filename : COPYALGO.ASM
; Last Modified : 23 Jan 2002.
; Version : 1.3
; Originator : Texas Instruments, DSP Digital Control Systems Group.
;--------------------------------------------------------------------------------------------------
; Description:
;
; This file contains implementations for routines that will be used in embedded
; flash algorithm applications to copy the flash algorithms from flash memory
; (load address) to RAM (run address). The flash programming routines for the
; TMS320LF240x device must be run from RAM
;--------------------------------------------------------------------------------------------------
;--------------------------------------------------------------------------------------------------
; Revision History
;
; Ver 1.0 (25 May 2001)
;
; Comments: New implementation for embeddable flash algos.
; Ver 1.1 (10 Aug 2001)
; Comments: No changes to this file. Incremented rev only.
; Ver 1.2 (16 Oct 2001)
; Comments: Fixed filename at top of file.
; Ver 1.3 (23 Jan 2002)
; Comments: Added stack save to all the function calls in this file.
; Specifically to, COPY_CLEAR_ALGO, COPY_ERASE_ALGO,
; COPY_PROGRAM_ALGO, and COPY_KERNEL.
;--------------------------------------------------------------------------------------------------
;--------------------------------------------------------------------------------------------------
;-------------------------------------------------------------------------------
; Import the flash symbol declarations (and any other things) in
; VAR.H
;-------------------------------------------------------------------------------
.include "..\include\var.h"
;-------------------------------------------------------------------------------
; Get the runtime address values for the clear, erase and program algorithms.
;-------------------------------------------------------------------------------
.include "..\include\rundefs.h"
;-------------------------------------------------------------------------------
; Export symols from this file are .globals in rundefs.h
;-------------------------------------------------------------------------------
;-------------------------------------------------------------------------------
; Define a template to put the counter variables in the flashAlgoVars block.
; This is unused at the time the copy is invoked, so the flashAlgoVars are not
; subject to trashing (since they are not yet created).
;-------------------------------------------------------------------------------
counterStruct .struct
source .int
dest .int
counter .int
temp .int
STACK0 .int
STACK1 .int
STACK2 .int
STACK3 .int
STACK4 .int
STACK5 .int
STACK6 .int
STACK7 .int
counter_len .endstruct
;-------------------------------------------------------------------------------
; Assign template to the flashAlgoVars block.
;-------------------------------------------------------------------------------
flashAlgoVars .tag counterStruct
;-------------------------------------------------------------------------------
; copyClearAlgo:
; This is the implementation of the ASM and C callable copy routine to copy
; the flash algorithms to the run address from the load address.
;-------------------------------------------------------------------------------
.text
COPY_CLEAR_ALGO: ;Assembly language call label.
_copyClearAlgo: ;C-language call label.
LDP #flashAlgoVars.source ;Point DP to the copy variables.
;STACK_SAVE:
LAR AR2,#flashAlgoVars.STACK0 ;Use AR2 to save the hardware stack.
MAR *,AR2 ;Make AR2 the current AR
RPT #7 ;Save all the 8 hardware stack locations
POPD *+ ;into RAM block.
;-------------------------------------------------------------------------------
; Process the main portion of the algorithm
;-------------------------------------------------------------------------------
LACC #ClearAlgoStartMain ;Point to the source of the clear
SACL flashAlgoVars.source ;algorithm.
LACC #ClearAlgoEndMain ;Compute the length of the algo
SUB #ClearAlgoStartMain ;to be copied, and then store
SACL flashAlgoVars.counter ;it back to the counter.
LACC #ClearAlgoRunMain ;Get the run address for the
;main clear algorithm.
SACL flashAlgoVars.dest ;Store the destination address.
CALL COPY_LOOP ;Call the core copy function.
;-------------------------------------------------------------------------------
; Copy the relocation sensitive portion of the algorithm
;-------------------------------------------------------------------------------
LACC #ClearAlgoStartSpl ;Point to the source of the clear
SACL flashAlgoVars.source ;algorithm.
LACC #ClearAlgoEndSpl ;Compute the length of the algo
SUB #ClearAlgoStartSpl ;to be copied, and then store
SACL flashAlgoVars.counter ;it back to the counter.
LACC #ClearAlgoRunSpl ;Get the run address for the
;main clear algorithm.
SACL flashAlgoVars.dest ;Store the destination address.
CALL COPY_LOOP ;Call the core copy function.
;--------------------------------------------------------------------------------------------------
; Restore the hardware stack and exit to caller.
;--------------------------------------------------------------------------------------------------
;STACK_RESTORE:
LAR AR2,#flashAlgoVars.STACK7 ;Point AR2 to the last of the stored stack contents
MAR *,AR2 ;Make AR2 the current AR
RPT #7 ;Restore ALL stack locations.
PSHD *-
MAR *,AR1 ;Make AR1 the current AR
RET ;Return to caller
;-------------------------------------------------------------------------------
; copyEraseAlgo:
; This is the implementation of the ASM and C callable copy routine to copy
; the flash algorithms to the run address from the load address.
;-------------------------------------------------------------------------------
COPY_ERASE_ALGO: ;Assembly language call label.
_copyEraseAlgo: ;C-language call label.
LDP #flashAlgoVars.source ;Point DP to the copy variables.
;STACK_SAVE:
LAR AR2,#flashAlgoVars.STACK0 ;Use AR2 to save the hardware stack.
MAR *,AR2 ;Make AR2 the current AR
RPT #7 ;Save all the 8 hardware stack locations
POPD *+ ;into RAM block.
;-------------------------------------------------------------------------------
; Process the main portion of the Erase algorithm
;-------------------------------------------------------------------------------
LACC #EraseAlgoStartMain ;Point to the source of the clear
SACL flashAlgoVars.source ;algorithm.
LACC #EraseAlgoEndMain ;Compute the length of the algo
SUB #EraseAlgoStartMain ;to be copied, and then store
SACL flashAlgoVars.counter ;it back to the counter.
LACC #EraseAlgoRunMain ;Get the run address for the
;main clear algorithm.
SACL flashAlgoVars.dest ;Store the destination address.
CALL COPY_LOOP ;Call the core copy function.
;-------------------------------------------------------------------------------
; Copy the relocation sensitive portion of the Erase algorithm
;-------------------------------------------------------------------------------
LACC #EraseAlgoStartSpl ;Point to the source of the clear
SACL flashAlgoVars.source ;algorithm.
LACC #EraseAlgoEndSpl ;Compute the length of the algo
SUB #EraseAlgoStartSpl ;to be copied, and then store
SACL flashAlgoVars.counter ;it back to the counter.
LACC #EraseAlgoRunSpl ;Get the run address for the
;main clear algorithm.
SACL flashAlgoVars.dest ;Store the destination address.
CALL COPY_LOOP ;Call the core copy function.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -