|
|
( T, Z" E6 S3 d在 ARM 端 StarterWare 例程中 CMD 文件比 DSP 端多了这样一句& t; p! P8 p; W: `
/* 重新配置程序入口点 */
6 O: @1 m* b- i9 l" s& _-e Entry- /****************************************************************************/' f+ G4 X% F5 ]2 X
- /* */6 B, ]' M- k; Z+ D2 U' R
- /* OMAPL138 及 DSP C6748 内存空间分配定义 */
' N7 Z) {7 ?' d- ? - /* */
2 ]3 F, @: \1 N) Y1 o8 | C+ z6 F - /* 2015年04月20日 */
$ b0 d. C6 e& r8 X0 f - /* */
! E6 [7 h: v8 G+ M - /****************************************************************************/
; G) v8 h. C8 ] - /* 堆栈 */
% U+ f9 R* ?) @- G1 `9 O( g. h - -stack 0x8000
; E6 @9 ]( @: D3 T" W% L - -heap 0x2000
c H8 s @+ T) F' W - * N) {8 j2 S4 u/ V% o
- /* 重新配置程序入口点 */
' c$ w6 ~/ h3 U E; S0 U$ C! T0 f - -e Entry
& q/ p1 m9 [* u! T
" ?, |. D0 S% b' B% E1 @- MEMORY
n" |$ K: a/ z( j8 Z3 R9 d - {( j7 R3 i8 w, @8 t/ i
- #ifdef DSP_CORE- N. M2 }, z0 O& _
- /****************************************************************************/! m$ ^& N% L3 N7 o) B* q& P
- /* */7 m+ b/ |" ^- z( n
- /* DSP 专有内存区域 */
5 C7 _7 k7 a2 V2 ? - /* */
" l4 D; Q' J5 |& }' | - /****************************************************************************/) R% r/ v' W8 e0 j8 h( ?
- DSPL2ROM o = 0x00700000 l = 0x00100000 /* 1MB L2 DSP 本地 ROM (DSP ROM Bootloader) */
$ D, N5 _- V, Z2 E0 E - DSPL2RAM o = 0x00800000 l = 0x00040000 /* 256kB L2 DSP 本地 RAM */
' v" g* B- y% }* Z8 G - DSPL1PRAM o = 0x00E00000 l = 0x00008000 /* 32kB L1 DSP 本地程序 RAM */
2 L) D8 `1 V( U5 c' M. \# K - DSPL1DRAM o = 0x00F00000 l = 0x00008000 /* 32kB L1 DSP 本地数据 RAM */
8 d1 l. k4 x7 C3 m; o8 G# b! R - #endif
复制代码 这是一段汇编代码用于切换到特权模式
1 ]" i, [" ]+ _+ w6 w4 _% l: x
9 y1 z- t5 m6 Z u9 n- ]1 F2 ^2 EOMAPL138_StarterWare_1_10_04_01\system_config\armv5\cgt\init.asm
3 o9 |- K z7 h! z: A+ V% Y- ;****************************************************************************** j/ U8 M$ M+ t3 n
- ;- M3 m/ r9 g6 L- f
- ; init.asm - Init code routines
, G" I! i& E: G3 X* [1 x$ [ - ;
: g" U6 N$ G3 P9 D6 m - ; Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/$ l& K& K6 B1 x
- ; All rights reserved." a4 v" P+ A+ `1 ~( X" V$ ~; m
- ;8 N# d$ s6 c! C' g/ r
- ;******************************************************************************
1 g) m1 c7 f+ y. x - ;****************************** Global Symbols*******************************! s( E: k4 g" r; d/ b' C
- .global Entry% t" E4 g3 F$ a
- .global start_boot
0 ^1 B) P4 U' ]8 _8 K4 Z$ M - .global __TI_auto_init
. T+ q0 A: E4 w8 s
4 n" W6 s/ W7 W% p- .ref __stack
$ f( |* D% s% C3 U' Y - .ref __STACK_END: Y' z1 d3 s \! ~/ j
- .ref bss_start. k/ G+ B2 W1 j6 t
- .ref bss_end2 J! X5 k+ P7 Z, k% o7 V* E) O% N
- .ref start_boot
2 @1 y3 p- P+ p: n) n. a2 X - " _( H" x' d; U5 }# |
- ;************************ Internal Definitions ******************************
- ^# Y/ p' H) Z% X: K6 E, i - ;
/ q/ K. @: h: Y/ d0 n5 M1 g% [ - ; Define the stack sizes for different modes. The user/system mode will use) v* p& Z1 C( t7 k; a3 K' M2 s, A
- ; the rest of the total stack size( ^( _2 A4 W$ R% ]* O- v; t& R
- ;: W/ q( O5 }. P# @
- 6 m) L4 }3 ~- }7 `
- UND_STACK_SIZE .set 0x8
6 C& c: s, y9 x# R, I - ABT_STACK_SIZE .set 0x8
% i- q1 j% N& |9 V* z" m - FIQ_STACK_SIZE .set 0x8' y8 C0 C/ ^' s; j
- IRQ_STACK_SIZE .set 0x5004 Q5 u+ ?, l/ m E; j, G4 P
- SVC_STACK_SIZE .set 0x8: Y$ S* A; g8 Z. z0 g% M
- $ P) |8 a+ F. c
- ;5 |8 w z5 d8 t" I0 m5 B, _7 R3 N& m
- ; to set the mode bits in CPSR for different modes, U( J2 K7 @: N+ [
- ;
( Q& u) U# n6 A$ L0 G
' R5 O7 x5 G; ]# n! B- MODE_USR .set 0x10) j4 d7 Y5 e/ v0 G8 R) U' |" `! Y
- MODE_FIQ .set 0x11
$ d6 A3 w1 U' A9 B5 R - MODE_IRQ .set 0x12: n4 w9 z: z( G
- MODE_SVC .set 0x13
5 J, r3 G! \( V) O& t - MODE_ABT .set 0x17- k1 q. ~9 _3 R* p6 R8 i
- MODE_UND .set 0x1B5 j& \' [9 o, Z
- MODE_SYS .set 0x1F
/ L& ?# y0 q+ y" i* u - ! e1 E* J9 z2 ~2 G2 z T V
- I_F_BIT .set 0xC0
! F9 F! q. d8 O4 f+ d
/ w% k2 n: y9 U3 A4 P/ {- ;**************************** Code Seection ***********************************- G+ Z; i4 p4 X
- .text
# K5 R- o- \5 i. c- H+ r - + W) c$ e+ d; ~
- ;+ i! o% ^! }* J# k: J, J% ^
- ; This code is assembled for ARM instructions
$ P: r* M! f# f; d - ;
4 g+ n$ ^" U* u, O' ?: h - .state32
7 `( f/ {. P; B" i5 P - ( o$ V8 {( s* G+ F" V# _% v
- ;******************************************************************************; R# u5 N8 E0 e( V3 K9 P% `
- ;9 x5 ~# q/ q) B( k+ R
- ;******************************************************************************
& Y# A9 B( w$ k$ V4 u% a1 T5 J+ ^ - ;
# E3 K4 O! j, C, C0 T6 H- { - ; The reset handler sets up the stack pointers for all the modes. The FIQ and
! D: {: X# A" j3 q0 P f - ; IRQ shall be disabled during this. Then, clearthe BSS sections, switch to the
* l+ _& `. f8 J1 P2 I. b- M - ; main() function.
/ r6 R) M' H4 h" N+ H3 U - ;
d% s! y* u, I9 ^' d$ z - Entry:% ?# v: z7 C: L
- ;& ^ j O% K) w2 [- H4 S
- ; Set up the Stack for Undefined mode
$ p' v) c' q7 d3 W( T0 j+ W - ;; y* l% r" Z5 k) C# }- F
- LDR r0, _stackptr ; Read and align the stack pointer
# p6 P* [9 ]. V/ N/ d' v - SUB r0, r0, #85 R% O, F. y7 \3 b) L
- BIC r0, r0, #7
6 Z" n8 q( w3 `' t - MSR cpsr_c, #MODE_UND|I_F_BIT ; switch to undef mode6 s2 e6 c5 q+ e% O6 H
- MOV sp,r0 ; write the stack pointer* t1 j/ F+ @8 Y6 W/ I
- SUB r0, r0, #UND_STACK_SIZE ; give stack space2 L; Z5 {6 j+ h; k
- ;
( B: e" j( R/ w* h6 E - ; Set up the Stack for abort mode
7 Z" z. F" P( } - ;
: Y% s# ^# a5 l: k5 j2 ~! F - MSR cpsr_c, #MODE_ABT|I_F_BIT ; Change to abort mode
5 ` ]9 c) a. X$ l - MOV sp, r0 ; write the stack pointer
/ U1 P+ @4 b2 Q2 g - SUB r0,r0, #ABT_STACK_SIZE ; give stack space
: x; P' N; d9 p! a - ;* P2 ]8 y0 G/ [) C# q$ \: F
- ; Set up the Stack for FIQ mode/ ~. P4 N0 t; v- F
- ;
$ o' G+ V4 t* ^ b$ p - MSR cpsr_c, #MODE_FIQ|I_F_BIT ; change to FIQ mode+ q: W( l+ c) @- Y+ o
- MOV sp,r0 ; write the stack pointer. h) t6 ]) ` [( M( f: Z6 r
- SUB r0,r0, #FIQ_STACK_SIZE ; give stack space5 B. a; d6 z9 G
- ;
9 `* X9 O m/ M7 W - ; Set up the Stack for IRQ mode$ g* N' X- D% x( B2 |) e
- ;
6 w% G l* s+ o; d1 z" W2 L$ L - MSR cpsr_c, #MODE_IRQ|I_F_BIT ; change to IRQ mode
. [& E! w% W3 Q1 p9 ]+ Z. f - MOV sp,r0 ; write the stack pointer
% P( D. D# r$ @# V- e" T7 r - SUB r0,r0, #IRQ_STACK_SIZE ; give stack space
3 r3 c8 Q4 L' G& D - ;; ^( ]" A" O) E7 S% Y& `2 H5 K
- ; Set up the Stack for SVC mode8 [* n5 m9 [& O4 `( c& P3 X+ |
- ;7 P/ @. p, G% p1 C
- MSR cpsr_c, #MODE_SVC|I_F_BIT ; change to SVC mode9 F# i( {4 A3 F& k+ K" H
- MOV sp,r0 ; write the stack pointer
! T: n6 H* K b - SUB r0,r0, #SVC_STACK_SIZE ; give stack space$ F8 l3 U K7 T O
- ;
[* V7 k2 r: w" d2 E, r% n - ; Set up the Stack for USer/System mode
+ v [6 W0 ^* g$ c9 @ - ;: R! v8 ]/ V# y5 O3 O1 f3 y
- MSR cpsr_c, #MODE_SYS|I_F_BIT ; change to system mode) J! P; F% _ B! t
- MOV sp,r0 ; write the stack pointer+ M. l: d7 F/ N" {
- 3 H! g6 i9 ?; f |) H
- ;( {* R. o2 f0 V T6 T. W; \
- ; Clear the BSS section here+ D1 C* d7 ?, g8 f* }1 n* ~4 h
- ;1 L7 s: k* u+ G
- Clear_Bss_Section:! m+ v% c; W" ^
- . T, l8 u+ ^; E
- LDR r0, _bss_start ; Start address of BSS
8 N0 `- r& k7 a - LDR r1, _bss_end ; End address of BSS
3 m' t- r/ r; N% k1 g* i. L - SUB r1,r1,#4! ~# V' e& d( S+ i8 m
- MOV r2, #0
1 a7 F) C$ x/ [7 d4 g# h0 x) i4 d - Loop:" t. z. h' v3 ]8 _
- STR r2, [r0], #4 ; Clear one word in BSS
9 J- E) R& P9 @ - CMP r0, r1
- G( {+ Z1 B, N* | - BLE Loop ; Clear till BSS end
. W! r1 N0 H7 Q _0 y" `
& h9 A L# Y2 k( K" w- BL __TI_auto_init ; Call TI auto init6 l) n( h' ?3 z* Y7 I
- * |( m/ k( S. K' {2 k# u
- ;
" o3 K; O3 n6 N1 |* F# ~ - ; Enter the start_boot function. The execution still happens in system mode
! d: \4 m' r. f; ] - ;5 C5 p% {* G3 P4 Q( H C* d
- LDR r10, _start_boot ; Get the address of start_boot; V: U7 n5 ]- s! _( j# @
- MOV lr,pc ; Dummy return * Y2 V$ p7 L2 i1 y8 s
- BX r10 ; Branch to start_boot
' B' w4 v6 ?9 w+ O9 x - SUB pc, pc, #0x08 ; looping
# R" P: c% I. b. C: C; {, l- F/ Q5 a - 0 p9 \$ f6 a% Y% r4 s# ^5 u
- ; MSR cpsr_c, #MODE_SVC|I_F_BIT ; change to SVC mode
2 |/ p5 w% a$ a4 \9 a. j9 f9 g i - ; BX lr
* F0 q) J/ |. J2 p/ _8 ` - ;. C ~1 B( t( s" N0 R; s" L
- ; End of the file+ z0 e, o7 `8 r; E" s
- ;
9 E/ i8 M' H2 M. s, l9 W - 3 T# {3 z( B0 K) {
- _stackptr:# [* k9 _+ P* c; B7 g7 H
- .word __STACK_END1 y" H* O- p5 ]# q& s
- _bss_start:
G, J1 ]2 i: T' U$ f - .word bss_start
* Q7 K n! ? J: ] - _bss_end:
4 W, U4 @; z q - .word bss_end
2 J7 j3 ]0 |' I - _start_boot:
8 E" ]# H! t8 N; Y: T- Z8 F. l - .word start_boot
# g+ i- k. d9 A2 H6 b" H - _data_auto_init:
d: i# ~; c. N) [ - .word __TI_auto_init( {% ?7 V% J4 z" C4 Q+ e2 Q+ s
- .end
2 s; }9 ]" a. o( y# d -
* n* R0 c8 D( t" u - 1 D/ E4 b: J6 K' Y2 _# h
- & _; d, l) a. O! P% F/ d
复制代码
1 f( E7 N9 e D4 A( ]
$ _' i: r$ l- _6 J& Z4 o0 U1 o& \$ I( V8 z' O3 N4 g2 Z, D
3 ~1 g5 o0 b4 J2 X6 D0 ]# v: C6 W
3 h4 G% A( j5 G3 k6 ? |
|