|
|
% G$ [5 i. u3 d1 o w在 ARM 端 StarterWare 例程中 CMD 文件比 DSP 端多了这样一句6 U$ Y+ B# h, Q O ]5 u$ ^
/* 重新配置程序入口点 */
. A5 x& G0 I* |- A; o; R3 Y-e Entry- /****************************************************************************/
1 S o( f+ C8 _. d - /* */( |5 ^4 ~3 x% Q5 r+ c3 T/ ]
- /* OMAPL138 及 DSP C6748 内存空间分配定义 */. w5 b/ o: [+ N l# |# u
- /* */& X* \& v# L6 S6 `/ r) ~9 M, _
- /* 2015年04月20日 */" R# a; i4 P$ T, W# }
- /* */
$ X* @8 ^" r6 E' [: C( B, D - /****************************************************************************/
1 `/ I2 L+ \1 i% I - /* 堆栈 */% B& o8 w" \" X, ? t- T4 K/ x
- -stack 0x8000
1 i+ A1 N9 W8 H6 D I$ U - -heap 0x2000
' V9 B- L7 [& \& a& C: D8 G
3 C( I7 |/ d& q6 x N1 Z7 O- /* 重新配置程序入口点 */3 G8 t% Z+ B, Y: S& w; }* ~: z
- -e Entry5 w5 }& z! x$ B: m
# w4 a U. M1 K( Y- MEMORY8 w4 z: |3 }( Y+ {0 ?
- {( R. `! k% [& U6 a7 G: d* [
- #ifdef DSP_CORE" y0 e5 q6 s+ I3 O& ~0 |
- /****************************************************************************/
. w& u& ?* [; v6 `9 ?: V - /* */' t- \0 Z' p* H0 _; t. G* H2 j5 u
- /* DSP 专有内存区域 */
& u' v7 q7 H" } - /* */. C: O2 F/ T. O; T6 w) q1 ]
- /****************************************************************************/, ~ Z& s& O; f" N+ |! p
- DSPL2ROM o = 0x00700000 l = 0x00100000 /* 1MB L2 DSP 本地 ROM (DSP ROM Bootloader) */; f* b4 ` q& a$ x% l Z: ^0 q* D
- DSPL2RAM o = 0x00800000 l = 0x00040000 /* 256kB L2 DSP 本地 RAM */
; L) ~' L1 O( m1 w3 k' u# C - DSPL1PRAM o = 0x00E00000 l = 0x00008000 /* 32kB L1 DSP 本地程序 RAM */6 A% u5 `# W: W! i; [/ Q3 m
- DSPL1DRAM o = 0x00F00000 l = 0x00008000 /* 32kB L1 DSP 本地数据 RAM */( g ~7 S& V2 m! b- E
- #endif
复制代码 这是一段汇编代码用于切换到特权模式$ d4 [. a6 b8 v, A+ B# e, u3 N+ ~) K
7 @0 K) _) |( ~
OMAPL138_StarterWare_1_10_04_01\system_config\armv5\cgt\init.asm
2 b: O5 j' g W: a- ;******************************************************************************
/ a- `6 A" A- D - ;2 ]6 R/ c b1 T% Q |
- ; init.asm - Init code routines, N! l; m1 f4 x7 x) ]7 A8 O8 _ O
- ;
" G& o6 H2 T3 Y+ D+ M# m5 s. K - ; Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/) W) ]% Q+ W, p% h5 q9 {# i4 K
- ; All rights reserved.
! o2 G( Y7 L( o e" s1 U - ;# H6 x- n9 D4 g+ J/ B7 n
- ;******************************************************************************
+ f6 Z8 u/ h+ g9 O - ;****************************** Global Symbols******************************* j5 A+ x& j1 U2 ~
- .global Entry
0 m% A7 A# K2 E0 i9 L. x- L7 |/ h - .global start_boot, J1 k' ?5 s, }$ T9 F
- .global __TI_auto_init
6 {! `/ T8 R3 u8 s - 0 e: N9 [8 J" x# f7 ^) `5 @
- .ref __stack$ f( q6 t. v* [- {
- .ref __STACK_END
Z9 \, X0 m0 P2 O( N; m - .ref bss_start
. p6 A) z" l8 S& i# o# W& e - .ref bss_end
% L/ S) J3 _4 v. F3 C+ c' y - .ref start_boot
* s6 m8 n6 p5 F6 \7 [ - ' i) ^ K; O5 v/ T6 N
- ;************************ Internal Definitions ******************************, n% T3 n% i4 S" ^/ ^: T5 ~
- ;
& z6 x9 f1 w) L% a/ w+ D# @, I - ; Define the stack sizes for different modes. The user/system mode will use6 C6 |6 @4 u3 m9 `$ I- _
- ; the rest of the total stack size- d, N; ?1 F& U( E! V6 b( \/ X* b# L
- ;
7 D$ D. ~5 k5 V a - % v5 z+ O. n/ M# h% ?$ Q
- UND_STACK_SIZE .set 0x8& \/ E4 G- E& O- ]
- ABT_STACK_SIZE .set 0x8) u; {9 y6 S3 T# K# s r
- FIQ_STACK_SIZE .set 0x87 o9 q) s" Z2 w% A! B: @
- IRQ_STACK_SIZE .set 0x500
- z! `2 }- h# s4 s2 I - SVC_STACK_SIZE .set 0x8
4 h: p q2 b8 U4 m. |( V3 C+ `) d/ _ - . `9 _8 X7 B+ \) H
- ;( s1 [2 p3 z# m- {: Y, m
- ; to set the mode bits in CPSR for different modes
% C! N2 N, m- E5 w - ;
" K4 W+ R( ?: o - 3 S2 J8 G3 t6 w9 t
- MODE_USR .set 0x10
! v+ L8 L, c+ { - MODE_FIQ .set 0x11
0 E6 K. o: ^! ]/ l9 C/ V - MODE_IRQ .set 0x127 {+ P# Z8 t* ~
- MODE_SVC .set 0x13& Z; u0 D [6 T+ P2 C K
- MODE_ABT .set 0x175 H/ e9 V: J& m, @2 n8 N3 G7 ^
- MODE_UND .set 0x1B
2 }2 w s, c, g - MODE_SYS .set 0x1F
) v! g3 z$ n+ Q7 R8 ] - 3 X: s- e( T' O9 }* ~/ {( K& b+ j" H
- I_F_BIT .set 0xC0
5 h+ x) ~. ?% R% r; h - ( H |2 Z- E m" m/ d5 ]; c" {5 d: y) k
- ;**************************** Code Seection ***********************************; p6 _& i1 J3 e& a9 w) v X
- .text
4 J% Y+ I6 W4 ~
4 a1 C# `% Z+ U4 J4 o- ;
! C7 d0 z( p' [! k, i, ]0 C - ; This code is assembled for ARM instructions4 w# h2 n0 I$ D8 c$ ]; m `; o% o; v
- ;
$ I+ Y6 N" e K1 S8 L - .state32* N Z# J) S: K- U3 z) ~! `
- D5 C3 i+ b/ j4 n& T- ;******************************************************************************9 j ^) T% J* w) F8 X+ _
- ;# B; Q" s/ e& J4 W! W6 H
- ;******************************************************************************
' T4 X3 S7 o5 P- c - ;
- r2 ?* G! R$ I - ; The reset handler sets up the stack pointers for all the modes. The FIQ and
" K3 I v+ F' ]/ T) M/ Y - ; IRQ shall be disabled during this. Then, clearthe BSS sections, switch to the1 I# _2 a2 |5 t8 x
- ; main() function.
7 U% L4 |) e' \# E. x - ;
3 L% T" \' R, r - Entry:
# O$ E; s- \$ x# y - ;
# B" p0 ^. F7 j* T - ; Set up the Stack for Undefined mode# r4 u) T6 f+ z
- ;
: T/ s. _/ U4 F6 V0 `8 u - LDR r0, _stackptr ; Read and align the stack pointer$ t. u# p/ h$ X" h+ b% q' u4 Y
- SUB r0, r0, #8) T J0 w9 W9 f5 H1 X% Q" b
- BIC r0, r0, #74 q* U, N; \: s- X8 I8 X% s
- MSR cpsr_c, #MODE_UND|I_F_BIT ; switch to undef mode
) p X/ n: D% l `0 v( l$ u8 g - MOV sp,r0 ; write the stack pointer
4 E. T1 a4 V+ p2 J" j - SUB r0, r0, #UND_STACK_SIZE ; give stack space
4 S5 {* j( k% u" f# g M8 v - ;
9 S& H, ]. F. A - ; Set up the Stack for abort mode
. o$ ?: A( H+ n7 g4 Y - ;
: l7 K9 s+ e, z) r - MSR cpsr_c, #MODE_ABT|I_F_BIT ; Change to abort mode* [% p1 L, F' P6 i* Y
- MOV sp, r0 ; write the stack pointer( h% w1 H, F: ]* V/ M- [
- SUB r0,r0, #ABT_STACK_SIZE ; give stack space0 y/ U7 ?! G6 f5 t; [
- ;& Z. Y; q7 w9 @
- ; Set up the Stack for FIQ mode3 P# _. I+ j4 P/ {
- ;
; C3 X; F" ^4 \/ Z- B: F' t - MSR cpsr_c, #MODE_FIQ|I_F_BIT ; change to FIQ mode" g' b/ c2 h) n& s7 G, u( O. u
- MOV sp,r0 ; write the stack pointer) ]4 X2 @; U# g2 u
- SUB r0,r0, #FIQ_STACK_SIZE ; give stack space* C- i4 @0 B1 L$ l. [6 D
- ;, Q6 J9 ?+ C! [
- ; Set up the Stack for IRQ mode
' S, @* ^1 W, H, W8 O - ;8 Z# S+ q2 _7 ]
- MSR cpsr_c, #MODE_IRQ|I_F_BIT ; change to IRQ mode4 s+ Q& Q. Z" V3 s1 `
- MOV sp,r0 ; write the stack pointer
) \, ^1 k, M- ~. H7 q, h - SUB r0,r0, #IRQ_STACK_SIZE ; give stack space
Y' G# r' }/ k- Y4 e b - ;
( f; V8 v- A% T' P4 S5 B+ C4 a7 M - ; Set up the Stack for SVC mode
2 h9 S4 M; M. ?& M( N; G( z& K; A - ;
: t: Y6 y. [: s& p( Z1 G - MSR cpsr_c, #MODE_SVC|I_F_BIT ; change to SVC mode9 ]3 d( |( g9 X9 X
- MOV sp,r0 ; write the stack pointer, f) _6 C! G4 F0 @& k
- SUB r0,r0, #SVC_STACK_SIZE ; give stack space; @: u( W; `# [3 M
- ;+ ]( ]+ Y Z/ @7 F% z
- ; Set up the Stack for USer/System mode
5 X* u, e, ^- W1 h% X1 I - ;6 {2 E) H' ?. d! b: [1 K0 d% r
- MSR cpsr_c, #MODE_SYS|I_F_BIT ; change to system mode1 [7 k; ^5 g( q9 ?0 s& A9 p b
- MOV sp,r0 ; write the stack pointer
' {+ D& r+ s1 l - - q g: R* I/ L0 n+ @, K
- ;
4 `/ L3 p* \: g% @0 P2 f/ ~6 g7 V - ; Clear the BSS section here
7 x3 |7 l& Y4 O' b s+ V - ;
1 \' C c6 R+ a# P$ l) |# x4 Z - Clear_Bss_Section:5 i7 h0 ~& y1 G5 I
, ~/ L: P+ s9 q' ?( p- LDR r0, _bss_start ; Start address of BSS1 T( m$ D1 |; L
- LDR r1, _bss_end ; End address of BSS
/ l% r9 t, s# A' ~% K! x - SUB r1,r1,#4) I u, Z$ |+ Z) m9 ?
- MOV r2, #0$ h: [8 X( T; o0 q* P3 A
- Loop:3 j! @: ~2 f4 K7 G" h$ X
- STR r2, [r0], #4 ; Clear one word in BSS
/ G! L, `" g2 S$ ^+ A - CMP r0, r1
, r" t- u# m4 ^3 W7 p0 x$ m8 ` - BLE Loop ; Clear till BSS end
G! j9 ]( u1 y. G! n+ y
) \/ N, q0 K/ P% P4 c. H2 @0 r5 f- BL __TI_auto_init ; Call TI auto init- ?* d: P2 O. o! D7 Z J
- G- y8 A+ U. d) H5 d0 N: M
- ;
/ R* J8 Q3 H" h, N - ; Enter the start_boot function. The execution still happens in system mode
! z) C& X0 G, h# {# I8 N - ;0 p; D9 C0 k: }/ K2 c
- LDR r10, _start_boot ; Get the address of start_boot
$ u0 x4 j8 D* p- t) b1 c - MOV lr,pc ; Dummy return , B5 S2 @6 q$ ~1 B, J- A
- BX r10 ; Branch to start_boot0 M4 e" Y! E" V# [' c+ o1 ^+ n
- SUB pc, pc, #0x08 ; looping! D: w$ V0 `& E( S5 S
- 4 {5 |: K6 f _( i) r3 A. N
- ; MSR cpsr_c, #MODE_SVC|I_F_BIT ; change to SVC mode5 ]4 ]( N. J3 ?3 S
- ; BX lr
* f0 Y* v _) H; n% g6 q$ E - ;
% R; a$ c; K' m1 z/ U# b - ; End of the file- ?: s2 ?& V) H
- ;1 P5 ^& p. F6 h. Y# S) R8 n
s6 k# |1 q6 S- _stackptr:
( \: \7 k' U0 B# @. k - .word __STACK_END
" G" G" I% m% g( E) V - _bss_start:5 m" W F2 p c
- .word bss_start* r6 g9 ]8 Q2 n1 Q+ P
- _bss_end:; v( I& @! g2 A7 @% k" F
- .word bss_end
; F q4 Y6 l) m' _' `9 z9 w7 t, L - _start_boot:! G* W- d M4 M+ J. R- w
- .word start_boot
* i+ p: w9 n- V6 D - _data_auto_init:$ ] Z7 S( j0 B7 x5 N: r; x/ B
- .word __TI_auto_init4 V. e- k6 G7 T& S' `
- .end/ @( ^$ ^/ e! ^9 N1 ^# n. I' U3 a
- ' X, |: P8 \4 S3 A4 n1 m0 w
- 6 T7 u+ s \4 T7 c) P* \ F
& j$ v9 p( c/ F6 F) }, z
复制代码 % w6 {4 Z, [* F4 S% s# ~# m
5 ^% L1 |2 h q; w$ d
, T# x6 h; }- U# m- J, I
, a; }; `! N! w( a
" z. K* B8 I- W1 x* u |
|