|
|
; A6 T/ e8 x3 O k- j
在 ARM 端 StarterWare 例程中 CMD 文件比 DSP 端多了这样一句 ^$ v3 g( A+ k2 I* H d( g% R
/* 重新配置程序入口点 */
6 V2 [0 v9 T/ j% A' W8 B-e Entry- /****************************************************************************/8 x6 k* h8 a: E3 q$ Q, z
- /* */
+ U$ h/ ?5 ^/ g8 p" U5 c - /* OMAPL138 及 DSP C6748 内存空间分配定义 */
& w4 E7 J# ]2 v- A1 D) E. k* b - /* */! J2 d9 P, ^' ~1 b1 V. y0 ^2 L
- /* 2015年04月20日 */, P$ w( \' J( G0 _: j. e) v! a
- /* */. Q" H/ p7 h& [8 K$ V* z c! i6 \$ S l
- /****************************************************************************/
# y7 l6 q9 s7 t, k- j8 ~ - /* 堆栈 */
$ N% Y, ]! a9 S9 O' M6 M - -stack 0x8000
A( V$ N: \4 E7 S. h9 c' d: } - -heap 0x20003 K+ f% H( {* L: E) Y
- 8 ]" g P3 o4 a6 k. E# s0 C7 @
- /* 重新配置程序入口点 */5 D3 z0 p3 l7 ^# K4 b
- -e Entry8 V5 l+ s& l4 q! C P7 [3 O
- * {+ w" B& [& v9 i+ z. c2 S2 p
- MEMORY6 W( h1 L, w6 X* I# Z7 ~
- {
. t t% d6 g1 h3 y - #ifdef DSP_CORE; n4 F1 ?1 G! y& X. h6 Z
- /****************************************************************************/& ^6 j3 v5 _* i8 @; R8 b1 T
- /* */
: i7 j, u; K2 O. }7 H4 U+ S8 Z - /* DSP 专有内存区域 */
- E0 l6 a5 m# Y. a$ [ - /* */$ l/ x" l9 i9 S2 ~
- /****************************************************************************/- P8 B( I# |! J6 k
- DSPL2ROM o = 0x00700000 l = 0x00100000 /* 1MB L2 DSP 本地 ROM (DSP ROM Bootloader) */
* L4 M2 M/ ~/ s4 e# C" _6 O* I, I+ d/ C - DSPL2RAM o = 0x00800000 l = 0x00040000 /* 256kB L2 DSP 本地 RAM */
8 t: }5 h t- o5 q# P9 K- S - DSPL1PRAM o = 0x00E00000 l = 0x00008000 /* 32kB L1 DSP 本地程序 RAM */
! D; j( W3 L: C& l# @8 B4 K) W - DSPL1DRAM o = 0x00F00000 l = 0x00008000 /* 32kB L1 DSP 本地数据 RAM */
$ I# `6 I% }+ g1 @# F& b - #endif
复制代码 这是一段汇编代码用于切换到特权模式
/ Q. y o) K( B+ `% P$ P6 {$ `7 s. K7 F0 G0 R5 ~# t4 t' O! d
OMAPL138_StarterWare_1_10_04_01\system_config\armv5\cgt\init.asm
, e. e/ B/ L! n# g8 T( a* o- ;******************************************************************************: d7 G# u, t5 U9 e8 R
- ;$ V) V7 Q( m$ F# f
- ; init.asm - Init code routines
3 Z6 F+ ~, O$ S* o - ;
: i6 ]) d6 ^! V& _3 N. n" _5 O/ N - ; Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
1 ~5 t( E4 |3 o: W( Z0 V8 ]/ r - ; All rights reserved.. I% C* F: [/ Q# W3 w b
- ;& [2 I7 g9 G3 H
- ;******************************************************************************
5 Z' F* ]. t. y% ?8 Y' p - ;****************************** Global Symbols*******************************
^" b3 P& A( b6 c7 w - .global Entry
0 `) P8 }4 d. x - .global start_boot
6 f1 ]" Q) q/ i - .global __TI_auto_init
2 b5 S$ o$ Z# g7 V I/ U6 D; w
. ~) v5 z4 L% a/ R- .ref __stack
) p5 e, K3 W: J& @, m# I8 v0 e - .ref __STACK_END
' X" G7 F/ ?4 b( B% R e - .ref bss_start1 J9 a2 M( M. `; t9 z1 W, ^
- .ref bss_end
7 Z2 H7 `3 m$ d6 W) ^- ]* R - .ref start_boot4 o1 O( m9 Z2 H, J
- ) u& R6 i9 X' h2 D' J& z+ t( Y. f! M
- ;************************ Internal Definitions ******************************
, C. ]* X. x _ - ;: g+ q" p) O) E$ h
- ; Define the stack sizes for different modes. The user/system mode will use5 @: }6 o& S9 D! s
- ; the rest of the total stack size
% m. @6 G0 [) c: D! _ - ;
: O) S& r% P% C; @3 f8 R
2 g# a& i4 o% q* C. ?- UND_STACK_SIZE .set 0x8
# Q! q7 R7 g" I9 y1 X - ABT_STACK_SIZE .set 0x8# y# {: d1 T) w3 b- d
- FIQ_STACK_SIZE .set 0x8; k. d, U; V4 t- g
- IRQ_STACK_SIZE .set 0x500
: {4 e2 F( o+ B5 \" m# b) a! [% R! { - SVC_STACK_SIZE .set 0x8
+ k1 T+ W" [/ [: V, Y
3 c: R% E! ]" C# K& o- ;, }' S. V# `; i: t2 D
- ; to set the mode bits in CPSR for different modes
9 p5 t& i9 Z3 i% Z' { - ;4 h N F0 J& ?2 q$ C" N: U
a0 }: N- [$ G- MODE_USR .set 0x10
$ @7 L; B' g) l5 w4 f8 I$ q% Q2 p5 l - MODE_FIQ .set 0x11
0 G7 w( g* B8 ~3 G3 w - MODE_IRQ .set 0x12, @" w6 Z! B4 q! ~: Z. T
- MODE_SVC .set 0x13 ]% O1 A! L7 c& q* x2 v
- MODE_ABT .set 0x173 T+ L& ~8 H' d5 s! C& ]; Q
- MODE_UND .set 0x1B
; A& Q% F* q) u - MODE_SYS .set 0x1F( j- T. S* E- f2 }# S
- 2 ~# R3 q% v$ z% D+ A- | d
- I_F_BIT .set 0xC0
" U }- i9 F) Y. Y1 b2 {3 L' T' m* u( j - 4 S, x3 D1 @' l
- ;**************************** Code Seection ***********************************
' ~8 ]" q! K% O4 `; c5 y - .text
: a4 x, d5 K, H* S - / H4 P) b. s: @+ B+ [
- ;, O: i( ]. p v4 Z" m: u$ N4 R
- ; This code is assembled for ARM instructions( \2 h2 t* M: K. Y7 [' Y7 Y
- ;
) t9 ?; R) V0 j) v) p5 @& S - .state32
5 X9 i7 |6 l* C6 u! {3 G
4 j8 t2 \6 ]. H- ;******************************************************************************
5 ?7 N5 R! W! T) h) _ - ;
2 J. R8 y1 S: [) t; B" ^* c& K - ;******************************************************************************, o; K+ q- K# W6 v' d4 Z+ K( b
- ;; G8 a3 _/ D3 q, D6 i1 S& Z
- ; The reset handler sets up the stack pointers for all the modes. The FIQ and
2 ?. K( U; f( f k$ U8 S - ; IRQ shall be disabled during this. Then, clearthe BSS sections, switch to the& {+ J! [6 B7 k
- ; main() function.
- ~- P7 I2 ? s' Y* z: J - ;- w y& r5 H. C! l* N* x. Z
- Entry:
0 V6 q. v8 o5 ?2 B( I - ;
# Y7 J7 }% Z9 j5 `4 o - ; Set up the Stack for Undefined mode
% ]. M; B+ U) _ G7 l - ;6 |( b/ Z& i+ \5 ], a1 X
- LDR r0, _stackptr ; Read and align the stack pointer. [; V3 }: B* W9 i4 {
- SUB r0, r0, #8
; d5 J2 f9 A& c, `" F2 ~ - BIC r0, r0, #71 U& @6 n2 \# C3 |8 n1 G
- MSR cpsr_c, #MODE_UND|I_F_BIT ; switch to undef mode$ `' ?" H$ c" F1 J
- MOV sp,r0 ; write the stack pointer
" R$ m& W2 Y* |4 T1 Z) @. M - SUB r0, r0, #UND_STACK_SIZE ; give stack space! ]5 Y9 h; A3 i
- ;. B; T, _( I# [' L% i% y/ R6 N1 i3 y
- ; Set up the Stack for abort mode5 L1 m8 T) F7 L4 y O4 v
- ;7 x2 ?" ~1 m; J4 D4 c# j8 F; D
- MSR cpsr_c, #MODE_ABT|I_F_BIT ; Change to abort mode$ r7 n4 L5 L' s# X- s @
- MOV sp, r0 ; write the stack pointer
8 B2 W$ e$ R) p, h, m) f& R - SUB r0,r0, #ABT_STACK_SIZE ; give stack space+ \$ ^" `5 L! G5 p- H# h. H+ C7 t
- ;# {9 }' ]( \ o% |) S+ T* r
- ; Set up the Stack for FIQ mode
' |4 w% a, y" y; V - ;8 ^; x0 {% I$ N' i
- MSR cpsr_c, #MODE_FIQ|I_F_BIT ; change to FIQ mode
; ]( u3 w/ ?" r& s8 V" I, J" P2 _ - MOV sp,r0 ; write the stack pointer# B/ c; I$ }4 i# K! q7 _
- SUB r0,r0, #FIQ_STACK_SIZE ; give stack space; }( [6 @' D0 R& `9 X
- ;! D1 f8 y# u E; _) s; j" Y
- ; Set up the Stack for IRQ mode
, H9 n/ m V8 X# t5 n' r+ L/ F% C - ;" n6 j# Y, b$ j2 {
- MSR cpsr_c, #MODE_IRQ|I_F_BIT ; change to IRQ mode
+ ~' Q# Z, K9 J7 U6 x5 X& M - MOV sp,r0 ; write the stack pointer; h! E% n9 v: K3 w. j6 j! G
- SUB r0,r0, #IRQ_STACK_SIZE ; give stack space" `; t/ N# n; O6 D- ~
- ;
& }3 f4 M" g1 R7 v+ ^9 `/ m; @( l - ; Set up the Stack for SVC mode' n7 N& ~7 T. I" ]
- ;4 K/ }- a N) d0 V( D+ Z# L& q
- MSR cpsr_c, #MODE_SVC|I_F_BIT ; change to SVC mode
7 Q- @' h% k0 g5 z9 c1 c. b - MOV sp,r0 ; write the stack pointer
+ n* Q+ z$ M' A0 I2 d# c4 _ L - SUB r0,r0, #SVC_STACK_SIZE ; give stack space n* R4 A; D+ l, x7 g/ n1 _( |+ s
- ;8 B! ]" j2 m$ ` f
- ; Set up the Stack for USer/System mode
% E$ V5 V# ?3 h7 K - ;
, N _, G3 P9 G1 B' C, m/ [ - MSR cpsr_c, #MODE_SYS|I_F_BIT ; change to system mode
& i3 O1 _; L, Y" e7 v( j - MOV sp,r0 ; write the stack pointer! [: R1 [+ d: }9 M# {2 k" e
# W1 t4 C' X+ a( ~- g4 x- ;
" W5 s; K U1 F7 a0 i' f - ; Clear the BSS section here. J! F, Y$ ]- c, I
- ; a5 I* O. j1 P, ~
- Clear_Bss_Section:
3 r4 B# o) p; ~. f
1 e V' Z* r, O" w2 j: n/ j% ~$ Q- LDR r0, _bss_start ; Start address of BSS
) U. A5 n1 h. j0 R$ d6 J( b - LDR r1, _bss_end ; End address of BSS
8 U; E/ a3 ?4 z - SUB r1,r1,#4
3 | V! j6 ^4 q! M - MOV r2, #0
- T8 a# ~3 j$ ^! {6 u - Loop:
5 ~6 X5 ?. @& S) q6 A - STR r2, [r0], #4 ; Clear one word in BSS
2 x+ l$ v& d' w. h3 H - CMP r0, r1
1 _0 o+ y( |+ O. t. j. Z - BLE Loop ; Clear till BSS end
4 b1 Q0 t2 y. b3 [, w$ g, S( F
( m- f1 p4 C( M9 Q- BL __TI_auto_init ; Call TI auto init
1 d! w. l: o- }5 c. k
( n4 f( d9 v1 g! @' N2 x- T- \' J( B. {- ;
' x E$ P2 J" M6 b - ; Enter the start_boot function. The execution still happens in system mode" `" w2 D0 O# I+ Z
- ;
- k3 p* Y' ? g8 q; M2 a - LDR r10, _start_boot ; Get the address of start_boot! z( a4 o! u) r+ X- @. c
- MOV lr,pc ; Dummy return + o# d) I0 g) z: i: f5 S) i' o% s
- BX r10 ; Branch to start_boot
2 l+ ?. A- L' [6 H7 b - SUB pc, pc, #0x08 ; looping. A+ a/ N+ m/ W% k( _& ?! |
- + s: g, u- ^1 v3 ^
- ; MSR cpsr_c, #MODE_SVC|I_F_BIT ; change to SVC mode! }1 |' M& E, D1 M7 J- W# Q
- ; BX lr
! M. L2 {2 z. [1 o4 A. w - ;
& K( T" j- g0 L* g% f% i% D' y - ; End of the file n& V! G, v# c: ^
- ;
) v. l( J1 Q# ^$ w; T v - ! j" f1 |) V" V. o. O
- _stackptr:
% m$ c, ^7 u* e1 Y - .word __STACK_END8 p/ a+ n% A* r$ p, x
- _bss_start: l. @- E2 u9 N B0 G
- .word bss_start
- A* r' U5 O. S) \5 [ - _bss_end:$ @% |* c0 R; N7 Y2 f# I
- .word bss_end
* V- b% P& w$ _0 }6 e - _start_boot:2 F3 {/ O8 ]9 u' d! d; d& k. r# B
- .word start_boot
9 K* y0 r7 w1 X$ @9 }! ` - _data_auto_init:
1 |" w7 c9 }5 D; [ - .word __TI_auto_init5 Q: t5 S2 _ d8 a8 b o
- .end
% t& n5 H! s: ]2 k b q ]5 [ -
2 B- s q4 P5 L1 A0 ~
0 T% s" g1 H; j& V
# G7 _& M3 A, B( u
复制代码 1 H9 ^ _5 k7 @
/ y. Q7 [2 x/ l0 I o0 D1 B
& [. l: i/ A3 k1 _, b9 O
; @% |/ l) n2 R6 c# G) {
|5 i0 ]* b% w8 d7 d. p
|
|