diff options
author | Jens Arnold <amiconn@rockbox.org> | 2005-11-28 23:40:57 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2005-11-28 23:40:57 +0000 |
commit | 104b81ea9a1a9c7b67e9e060fef4d0a97a547b7b (patch) | |
tree | 5234c4b9fe280b128bac7bc5ccbbeb7e7ac90915 /firmware/decompressor/startup.S | |
parent | d371141493a6863890e3867e5fef4f9c1b9d3add (diff) | |
download | rockbox-104b81ea9a1a9c7b67e9e060fef4d0a97a547b7b.tar.gz rockbox-104b81ea9a1a9c7b67e9e060fef4d0a97a547b7b.zip |
Fixed self-extracting loader: (1) Proper startup code, ensuring the stack pointer is set to the desired location. (2) Code cleanup.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8103 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/decompressor/startup.S')
-rwxr-xr-x | firmware/decompressor/startup.S | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/firmware/decompressor/startup.S b/firmware/decompressor/startup.S new file mode 100755 index 0000000000..62efef9cc3 --- /dev/null +++ b/firmware/decompressor/startup.S | |||
@@ -0,0 +1,57 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2005 by Jens Arnold | ||
11 | * based on crt0.S by Linus Nielsen Feltzing | ||
12 | * | ||
13 | * All files in this archive are subject to the GNU General Public License. | ||
14 | * See the file COPYING in the source tree root for full license agreement. | ||
15 | * | ||
16 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
17 | * KIND, either express or implied. | ||
18 | * | ||
19 | ****************************************************************************/ | ||
20 | .section .start,"ax",@progbits | ||
21 | .global _start | ||
22 | _start: | ||
23 | /* copy the .iram section */ | ||
24 | mov.l .iramcopy_k,r0 | ||
25 | mov.l .iram_k,r1 | ||
26 | mov.l .iramend_k,r2 | ||
27 | /* Note: We cannot put a PC relative load into the delay slot of a 'bra' | ||
28 | instruction (the offset would be wrong), but there is nothing else to | ||
29 | do before the loop, so the delay slot would be 'nop'. The cmp / bf | ||
30 | sequence is the same length, but more efficient. */ | ||
31 | cmp/hi r1,r2 | ||
32 | bf .noiramcopy | ||
33 | .iramloop: | ||
34 | mov.l @r0+,r3 | ||
35 | mov.l r3,@r1 | ||
36 | add #4,r1 | ||
37 | cmp/hi r1,r2 | ||
38 | bt .iramloop | ||
39 | .noiramcopy: | ||
40 | |||
41 | /* call the mainline */ | ||
42 | mov.l .main_k,r0 | ||
43 | mov.l .stackend_k,r15 | ||
44 | jmp @r0 | ||
45 | nop | ||
46 | |||
47 | .align 2 | ||
48 | .iramcopy_k: | ||
49 | .long _iramcopy | ||
50 | .iram_k: | ||
51 | .long _iramstart | ||
52 | .iramend_k: | ||
53 | .long _iramend | ||
54 | .stackend_k: | ||
55 | .long _stackend | ||
56 | .main_k: | ||
57 | .long _main | ||