|
. o1 w' |$ s5 H5 ^ L
在 ARM 端 StarterWare 例程中 CMD 文件比 DSP 端多了这样一句$ C0 L% c/ z; q/ z
/* 重新配置程序入口点 */7 r3 c7 I+ N) d2 V
-e Entry- /****************************************************************************/
+ |6 }- X, @# e5 { - /* */
) L) c: i6 `, G6 y( r( B( a - /* OMAPL138 及 DSP C6748 内存空间分配定义 */! N. N# Y2 W( G2 p
- /* */# R5 e. Y$ Q; A% L6 ]
- /* 2015年04月20日 */4 W2 v4 }# ~5 N$ e' M0 h1 P8 D! ?
- /* */4 x0 M, Y/ T ]& a
- /****************************************************************************/
: w5 n8 Q0 T! l1 `/ C# | - /* 堆栈 */) m" s* r* x( e% }8 W, z1 I6 P, r; v
- -stack 0x80009 t9 p* Z3 Y2 H9 i8 C4 q$ ~9 T: b& d
- -heap 0x2000
; }+ R! f. p% ?5 N, h
3 a4 J. G2 x1 Y* f/ j- /* 重新配置程序入口点 */0 Z- P( s* R7 L5 Q/ G- e- O
- -e Entry+ C4 k- `2 V% d
' a- }/ a* i! m. D9 a- MEMORY
# r7 p' X, K% s- ]" V - {
; I& u3 N: o' A6 D7 d2 l+ c - #ifdef DSP_CORE
: D9 n! i* A2 i7 V# x - /****************************************************************************/
( @' u7 Z4 G, b4 @ - /* */
, C O' B) U7 b$ D - /* DSP 专有内存区域 */! g9 a6 `9 n0 ]; n: E
- /* */, L' v% Y: p( v8 ]
- /****************************************************************************/
+ I& ^0 q( `8 |, D/ b0 s/ ]. ] - DSPL2ROM o = 0x00700000 l = 0x00100000 /* 1MB L2 DSP 本地 ROM (DSP ROM Bootloader) */
3 f2 j4 L; ~' X - DSPL2RAM o = 0x00800000 l = 0x00040000 /* 256kB L2 DSP 本地 RAM */
% T* {3 f( A% d1 H7 { - DSPL1PRAM o = 0x00E00000 l = 0x00008000 /* 32kB L1 DSP 本地程序 RAM */
) X$ A$ w5 n9 F0 }0 n6 A- B - DSPL1DRAM o = 0x00F00000 l = 0x00008000 /* 32kB L1 DSP 本地数据 RAM */
/ u! d9 A( `0 p - #endif
复制代码 这是一段汇编代码用于切换到特权模式) e2 @0 Q; c# K8 m7 q
5 Y; I" K7 l/ I5 Y
OMAPL138_StarterWare_1_10_04_01\system_config\armv5\cgt\init.asm3 `9 `" b: l0 V6 b6 C, u
- ;******************************************************************************
8 U) W2 I& E+ i- S9 A( p2 v4 A4 \ - ;
3 W+ L4 ~9 k( J4 r$ V/ V - ; init.asm - Init code routines& p! j" n$ |" Y* y
- ;
3 n5 o! l K% u; `5 y( X - ; Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
4 M- f# G1 ]9 \8 X" u' l - ; All rights reserved.
0 ?7 F. b/ [! K$ Y- Q7 D+ C$ n" n - ;
. p0 K& y) c4 b2 D. S: E - ;******************************************************************************
7 {7 @9 p3 D& l9 V7 b - ;****************************** Global Symbols*******************************8 `' q7 E5 F4 l
- .global Entry
$ W, _; u4 w5 \: K7 D# Q, D - .global start_boot
! f% t9 y. e# y - .global __TI_auto_init1 ]6 L$ ?2 i* v/ U9 P+ ]7 A) F
! s( i7 ^( B9 Y4 \6 F+ d$ Q- .ref __stack
! p0 @/ h2 d# \9 A3 I - .ref __STACK_END
5 b! D3 H; l5 t( \% ~7 E - .ref bss_start: Q. a& Z* L4 k3 l: |
- .ref bss_end. T h" w. u* j
- .ref start_boot2 }8 p. Q+ g' i1 c9 C3 D( o
- 0 B6 v6 p j$ ^& e+ y
- ;************************ Internal Definitions ******************************4 m2 G P; O. }4 U4 Y
- ;' F, \0 g3 o/ N
- ; Define the stack sizes for different modes. The user/system mode will use A4 w! `3 n% B+ S' S
- ; the rest of the total stack size) D1 f; n5 ^& M0 l% i [
- ;
s: c7 G' M8 a, l - ; }9 w( c! l6 \* g( e5 m
- UND_STACK_SIZE .set 0x8
& ^; K5 K3 }/ \: s. ^. N2 Y2 A1 _+ Z8 } - ABT_STACK_SIZE .set 0x8
% S. x+ t2 {( z6 S1 a) F - FIQ_STACK_SIZE .set 0x8& i0 g9 ?5 F2 k) G$ Q/ N8 B
- IRQ_STACK_SIZE .set 0x500
: X* O) m3 U+ j; i) N& M3 W - SVC_STACK_SIZE .set 0x8: e7 i9 D9 Q8 ^; x& j( G8 _
- ) D" p/ W# B; _) H6 [
- ;7 r5 H# X2 M; D8 e+ n
- ; to set the mode bits in CPSR for different modes7 o3 y/ ~; q$ Q2 L
- ;/ g& ~. C \- B5 d
- 1 v1 G+ ]+ j% ]. O
- MODE_USR .set 0x10
& ]% w* f, P1 E% Z3 V- | - MODE_FIQ .set 0x11) \: r1 F: i, Y8 S
- MODE_IRQ .set 0x12
5 k, n( B' H X: Q0 I, G8 \2 E2 V8 H - MODE_SVC .set 0x13$ X# z3 r. T- k
- MODE_ABT .set 0x17
: @: R( x" M" _ - MODE_UND .set 0x1B
8 U) z& x0 [. c4 Z# c5 X0 i - MODE_SYS .set 0x1F% R2 Q+ ^9 I% j% M
/ K$ {" `" `' z- I_F_BIT .set 0xC01 |( D2 ?8 q7 Z2 I& \! k: s
- , I* _8 i8 ]4 T4 o. J
- ;**************************** Code Seection ***********************************/ v. K1 F5 u. X) ~, g% \& y! z6 @
- .text
. c+ y9 Z/ h1 P; R7 \9 Q* t - 9 Y" w3 L, M) m- x3 t3 ?) \3 _
- ;% y. D' r \+ E1 H- e6 B
- ; This code is assembled for ARM instructions
5 D5 J& s, j' K2 C - ;8 P/ N0 Z# w, j/ \ S
- .state32( S% F- p! G. G
$ E" c: S8 }3 I- ;******************************************************************************
4 h0 U0 _: W0 ^ A - ;1 `) b+ ~/ W1 O% i: N0 ?" z1 X7 l
- ;******************************************************************************
# P$ f$ S4 f. F* w - ;
5 L& q/ J! u+ M& T3 U$ g - ; The reset handler sets up the stack pointers for all the modes. The FIQ and0 J3 g- e# r9 @, s7 K$ l
- ; IRQ shall be disabled during this. Then, clearthe BSS sections, switch to the1 ?: I- ^5 d) A; {0 o9 r. `
- ; main() function.
9 x; e' o8 q3 w5 W - ;
; g/ u9 f/ H( z; f% f! L4 X5 e7 G - Entry:" U7 c! M0 X$ P) u( U
- ;
& G+ j9 d; k) d* _$ Q; `7 c4 k - ; Set up the Stack for Undefined mode
2 t6 b, \# l" i, Q! F/ L - ;
2 C6 h9 _: J* o: D5 ^ - LDR r0, _stackptr ; Read and align the stack pointer, s9 c) n( R6 p4 w, O
- SUB r0, r0, #8
, e# E. p2 ?+ q1 \) c - BIC r0, r0, #70 R# K7 H5 b. z1 |8 l
- MSR cpsr_c, #MODE_UND|I_F_BIT ; switch to undef mode
% X6 L7 G5 E4 T+ J8 ~5 c - MOV sp,r0 ; write the stack pointer
B/ ], b% T/ F, Z2 }# O+ J - SUB r0, r0, #UND_STACK_SIZE ; give stack space
- Z1 [9 T7 s0 i& M9 a7 z. B2 } - ;# Z- D) Z8 U8 g
- ; Set up the Stack for abort mode+ P' _" I) B0 J, X
- ;
- ] q, a1 ^$ z9 ?: | - MSR cpsr_c, #MODE_ABT|I_F_BIT ; Change to abort mode3 \- B6 {7 V& q; M% e# m2 C l
- MOV sp, r0 ; write the stack pointer* o5 `( W! _3 N& b4 ?
- SUB r0,r0, #ABT_STACK_SIZE ; give stack space s5 t2 X+ M) b# u7 I" J" I- l
- ;
( }* r4 t; p+ x; n* Y - ; Set up the Stack for FIQ mode. T0 S5 \. h! y/ C6 V! N% X
- ;
' t7 `7 }+ x$ P+ \, { - MSR cpsr_c, #MODE_FIQ|I_F_BIT ; change to FIQ mode% }$ l9 ~. ?; G% [. p
- MOV sp,r0 ; write the stack pointer& q0 [: N; d" g5 `
- SUB r0,r0, #FIQ_STACK_SIZE ; give stack space* n% F" e |0 @) e
- ;/ H0 z( k5 s# o& f4 w2 j
- ; Set up the Stack for IRQ mode" d' K/ b* h! h4 w
- ;
: K0 {# ?5 @* q - MSR cpsr_c, #MODE_IRQ|I_F_BIT ; change to IRQ mode
. e1 G, Z8 q1 b! }! k+ f - MOV sp,r0 ; write the stack pointer* [' Z( x( Q% I6 `+ r0 Q
- SUB r0,r0, #IRQ_STACK_SIZE ; give stack space3 K: C" s P! c4 v, S; p& C i
- ;
6 j. B1 _# Y( I5 [ - ; Set up the Stack for SVC mode
6 K, T9 u4 U. |: A- B2 I/ b - ;
( z2 D5 y1 q+ R; H* E - MSR cpsr_c, #MODE_SVC|I_F_BIT ; change to SVC mode
& D, G, [4 m6 {& M1 ` - MOV sp,r0 ; write the stack pointer. G$ A4 e6 D* x5 f
- SUB r0,r0, #SVC_STACK_SIZE ; give stack space: C% p9 j0 i0 {8 e# |
- ;
' O$ c; h, i& p* h d; i d - ; Set up the Stack for USer/System mode
8 F* G9 \0 q! T( s/ v - ;
+ f6 x& m$ q& h5 T/ o9 k - MSR cpsr_c, #MODE_SYS|I_F_BIT ; change to system mode, U6 J8 J, h' [, a1 r/ y
- MOV sp,r0 ; write the stack pointer2 V0 S# Z2 w- A+ @4 p
; y3 [" F8 T1 r% d- ;3 D- ~! {0 G/ N. \9 d# L6 ~' p
- ; Clear the BSS section here
- w2 z& a% q" L& P# } - ;8 F- @! B& S6 R; t& F" ~& d: ^
- Clear_Bss_Section:
3 n" d) F1 @! ]: W - * n9 C* ~# F/ j+ N
- LDR r0, _bss_start ; Start address of BSS J+ i" i7 Y) Q" L% p4 a, V/ x
- LDR r1, _bss_end ; End address of BSS
6 V% h2 M; W# y - SUB r1,r1,#4
+ v3 W$ g' \! `# A& x% @ - MOV r2, #09 ?* L6 y9 t4 Y8 Q& p) k
- Loop:
0 b! J' J' G1 U - STR r2, [r0], #4 ; Clear one word in BSS
' t( o8 Z$ N! p8 [ - CMP r0, r1* M% B: }3 T% I. n6 G4 w
- BLE Loop ; Clear till BSS end0 B# r# E9 b3 j9 p
- " t( M5 ^8 ~ f l* _2 g
- BL __TI_auto_init ; Call TI auto init
& |- u5 K) X" t8 v g D
, M) U: ~4 q/ C. W! Z- ;
# ~3 n, c$ W0 B - ; Enter the start_boot function. The execution still happens in system mode
, W8 P* d# p) Z/ O( B+ B' _4 H - ;$ v$ m$ R" D$ M! u
- LDR r10, _start_boot ; Get the address of start_boot
0 _& N f: V3 ?8 r" _" U - MOV lr,pc ; Dummy return , N& N6 B. X z6 B7 g/ g
- BX r10 ; Branch to start_boot
1 C* }( h# |/ Z$ l _ - SUB pc, pc, #0x08 ; looping9 ?3 e( F* B' _* N4 x
! l+ ~- U) Q7 x( y" i% H& b! m- ; MSR cpsr_c, #MODE_SVC|I_F_BIT ; change to SVC mode2 |6 J- L9 o) Y9 y& Z
- ; BX lr* X. ]: p; T7 B' C' c8 @
- ;+ n l7 O# Z4 V
- ; End of the file
: o8 ^+ N0 [# d* N - ;5 J5 A/ _1 y: N$ ]! C
( H3 J p1 s6 q) p3 @# K: S- _stackptr:
- @* @8 {, d+ l - .word __STACK_END
; {3 g9 \6 h4 f1 Z - _bss_start:
9 }2 f: N, q8 z; ?; N9 {3 { - .word bss_start/ M' z8 j, o g
- _bss_end:
+ |7 Z0 B/ a2 x! `2 p - .word bss_end* `( g; h, j3 ]. Z- n6 H; p5 ~
- _start_boot:& j4 t2 `/ p, E5 ?
- .word start_boot u) x0 Y' o5 h
- _data_auto_init:% d) P0 |- w/ N" e; Q
- .word __TI_auto_init1 n$ I7 ?6 t2 x* J7 B8 N
- .end
8 T# _! e4 n- B- C f -
1 _* N+ a: z, B5 t
3 J% x- U! W# u. q
! N: |; d- c& M
复制代码
$ S- b4 Z7 K6 D+ u& [7 j5 P$ _. G) L5 P9 W' J
/ L. m1 O, e! a5 q9 F7 u
9 w. K$ R6 w2 E' b% F. G, k2 l/ e9 S( \$ e9 m# h5 l* X* W
|
|