source: rtems/c/src/lib/libbsp/arm/nds/start/start.S @ 12d853d

4.104.11
Last change on this file since 12d853d was 311dfa6, checked in by Joel Sherrill <joel.sherrill@…>, on Apr 16, 2008 at 6:37:33 PM

2008-04-16 Matthieu Bucchianeri <mbucchia@…>

  • ChangeLog?, Makefile.am, README, bsp_specs, configure.ac, mk_libnds.sh, patch.libnds, preinstall.am, block/block.c, clock/clock.c, console/console.c, coproc/coproc.S, coproc/coproc.c, coproc/coproc.ld, dswifi/dswifi_license.txt, dswifi/makefile, dswifi/arm7/makefile, dswifi/arm7/source/wifi_arm7.c, dswifi/arm7/source/wifi_arm7.h, dswifi/arm9/makefile, dswifi/arm9/source/sgIP.c, dswifi/arm9/source/sgIP.h, dswifi/arm9/source/sgIP_ARP.c, dswifi/arm9/source/sgIP_ARP.h, dswifi/arm9/source/sgIP_Config.h, dswifi/arm9/source/sgIP_DHCP.c, dswifi/arm9/source/sgIP_DHCP.h, dswifi/arm9/source/sgIP_DNS.c, dswifi/arm9/source/sgIP_DNS.h, dswifi/arm9/source/sgIP_Hub.c, dswifi/arm9/source/sgIP_Hub.h, dswifi/arm9/source/sgIP_ICMP.c, dswifi/arm9/source/sgIP_ICMP.h, dswifi/arm9/source/sgIP_IP.c, dswifi/arm9/source/sgIP_IP.h, dswifi/arm9/source/sgIP_TCP.c, dswifi/arm9/source/sgIP_TCP.h, dswifi/arm9/source/sgIP_UDP.c, dswifi/arm9/source/sgIP_UDP.h, dswifi/arm9/source/sgIP_memblock.c, dswifi/arm9/source/sgIP_memblock.h, dswifi/arm9/source/sgIP_sockets.c, dswifi/arm9/source/sgIP_sockets.h, dswifi/arm9/source/wifi_arm9.c, dswifi/arm9/source/wifi_arm9.h, dswifi/common/source/dsregs.h, dswifi/common/source/spinlock.h, dswifi/common/source/spinlock.s, dswifi/common/source/wifi_shared.h, dswifi/include/dswifi7.h, dswifi/include/dswifi9.h, dswifi/include/dswifi_version.h, dswifi/include/netdb.h, dswifi/include/sgIP_errno.h, dswifi/include/netinet/in.h, fb/fb.c, fb/fb.h, include/bsp.h, include/my_ipc.h, include/tm27.h, include/types.h, include/sys/iosupport.h, irq/irq.c, irq/irq.h, libfat/gba/include/fat.h, libfat/include/fat.h, libfat/nds/include/fat.h, libfat/source/bit_ops.h, libfat/source/cache.c, libfat/source/cache.h, libfat/source/common.h, libfat/source/directory.c, libfat/source/directory.h, libfat/source/fatdir.c, libfat/source/fatdir.h, libfat/source/fatfile.c, libfat/source/fatfile.h, libfat/source/file_allocation_table.c, libfat/source/file_allocation_table.h, libfat/source/filetime.c, libfat/source/filetime.h, libfat/source/libfat.c, libfat/source/mem_allocate.h, libfat/source/partition.c, libfat/source/partition.h, libfat/source/disc_io/disc.c, libfat/source/disc_io/disc.h, libfat/source/disc_io/disc_io.h, libfat/source/disc_io/io_cf_common.c, libfat/source/disc_io/io_cf_common.h, libfat/source/disc_io/io_dldi.h, libfat/source/disc_io/io_dldi.s, libfat/source/disc_io/io_efa2.c, libfat/source/disc_io/io_efa2.h, libfat/source/disc_io/io_fcsr.c, libfat/source/disc_io/io_fcsr.h, libfat/source/disc_io/io_m3_common.c, libfat/source/disc_io/io_m3_common.h, libfat/source/disc_io/io_m3cf.c, libfat/source/disc_io/io_m3cf.h, libfat/source/disc_io/io_m3sd.c, libfat/source/disc_io/io_m3sd.h, libfat/source/disc_io/io_mpcf.c, libfat/source/disc_io/io_mpcf.h, libfat/source/disc_io/io_njsd.c, libfat/source/disc_io/io_njsd.h, libfat/source/disc_io/io_nmmc.c, libfat/source/disc_io/io_nmmc.h, libfat/source/disc_io/io_sc_common.c, libfat/source/disc_io/io_sc_common.h, libfat/source/disc_io/io_sccf.c, libfat/source/disc_io/io_sccf.h, libfat/source/disc_io/io_scsd.c, libfat/source/disc_io/io_scsd.h, libfat/source/disc_io/io_scsd_s.s, libfat/source/disc_io/io_sd_common.c, libfat/source/disc_io/io_sd_common.h, libnds/Makefile.arm7, libnds/Makefile.arm9, libnds/libnds_license.txt, libnds/basicARM7/source/defaultARM7.c, libnds/include/default_font_bin.h, libnds/include/gbfs.h, libnds/include/nds.h, libnds/include/nds/bios.h, libnds/include/nds/card.h, libnds/include/nds/dma.h, libnds/include/nds/interrupts.h, libnds/include/nds/ipc.h, libnds/include/nds/jtypes.h, libnds/include/nds/memory.h, libnds/include/nds/registers_alt.h, libnds/include/nds/reload.h, libnds/include/nds/system.h, libnds/include/nds/timers.h, libnds/include/nds/arm7/audio.h, libnds/include/nds/arm7/clock.h, libnds/include/nds/arm7/serial.h, libnds/include/nds/arm7/touch.h, libnds/include/nds/arm9/background.h, libnds/include/nds/arm9/boxtest.h, libnds/include/nds/arm9/cache.h, libnds/include/nds/arm9/console.h, libnds/include/nds/arm9/exceptions.h, libnds/include/nds/arm9/image.h, libnds/include/nds/arm9/input.h, libnds/include/nds/arm9/math.h, libnds/include/nds/arm9/ndsmotion.h, libnds/include/nds/arm9/pcx.h, libnds/include/nds/arm9/postest.h, libnds/include/nds/arm9/rumble.h, libnds/include/nds/arm9/sound.h, libnds/include/nds/arm9/sprite.h, libnds/include/nds/arm9/trig_lut.h, libnds/include/nds/arm9/video.h, libnds/include/nds/arm9/videoGL.h, libnds/source/arm7/audio.c, libnds/source/arm7/clock.c, libnds/source/arm7/microphone.c, libnds/source/arm7/spi.c, libnds/source/arm7/touch.c, libnds/source/arm7/userSettings.c, libnds/source/arm9/COS.bin, libnds/source/arm9/COS.s, libnds/source/arm9/SIN.bin, libnds/source/arm9/SIN.s, libnds/source/arm9/TAN.bin, libnds/source/arm9/TAN.s, libnds/source/arm9/boxtest.c, libnds/source/arm9/console.c, libnds/source/arm9/dcache.s, libnds/source/arm9/default_font.bin, libnds/source/arm9/default_font.s, libnds/source/arm9/exceptionHandler.S, libnds/source/arm9/exceptionHandler.s, libnds/source/arm9/exceptions.c, libnds/source/arm9/gurumeditation.c, libnds/source/arm9/icache.s, libnds/source/arm9/image.c, libnds/source/arm9/initSystem.c, libnds/source/arm9/keys.c, libnds/source/arm9/ndsmotion.c, libnds/source/arm9/pcx.c, libnds/source/arm9/rumble.c, libnds/source/arm9/sound.c, libnds/source/arm9/system.c, libnds/source/arm9/touch.c, libnds/source/arm9/video.c, libnds/source/arm9/videoGL.c, libnds/source/common/biosCalls.s, libnds/source/common/card.c, libnds/source/common/gbfs.c, libnds/source/common/interruptDispatcher.s, libnds/source/common/interrupts.c, rtc/rtc.c, sound/sound.c, sound/sound.h, start/start.S, startup/linkcmds, startup/start.c, timer/timer.c, tools/Makefile.am, tools/bin2s, tools/bin2s.c, tools/configure.ac, tools/runtest, tools/ndstool/include/arm7_sha1_homebrew.h, tools/ndstool/include/arm7_sha1_nintendo.h, tools/ndstool/include/banner.h, tools/ndstool/include/bigint.h, tools/ndstool/include/crc.h, tools/ndstool/include/default_icon.h, tools/ndstool/include/encryption.h, tools/ndstool/include/header.h, tools/ndstool/include/hook.h, tools/ndstool/include/little.h, tools/ndstool/include/loadme.h, tools/ndstool/include/logo.h, tools/ndstool/include/ndscreate.h, tools/ndstool/include/ndsextract.h, tools/ndstool/include/ndstool.h, tools/ndstool/include/ndstree.h, tools/ndstool/include/overlay.h, tools/ndstool/include/passme.h, tools/ndstool/include/passme_sram.h, tools/ndstool/include/passme_vhd1.h, tools/ndstool/include/passme_vhd2.h, tools/ndstool/include/raster.h, tools/ndstool/include/sha1.h, tools/ndstool/include/types.h, tools/ndstool/source/arm7_sha1_homebrew.c, tools/ndstool/source/arm7_sha1_nintendo.c, tools/ndstool/source/banner.cpp, tools/ndstool/source/bigint.cpp, tools/ndstool/source/compile_date.c, tools/ndstool/source/crc.cpp, tools/ndstool/source/default_icon.c, tools/ndstool/source/encryption.cpp, tools/ndstool/source/header.cpp, tools/ndstool/source/hook.cpp, tools/ndstool/source/loadme.c, tools/ndstool/source/logo.cpp, tools/ndstool/source/ndscodes.cpp, tools/ndstool/source/ndscreate.cpp, tools/ndstool/source/ndsextract.cpp, tools/ndstool/source/ndstool.cpp, tools/ndstool/source/ndstree.cpp, tools/ndstool/source/passme.cpp, tools/ndstool/source/passme_sram.c, tools/ndstool/source/raster.cpp, tools/ndstool/source/sha1.cpp, touchscreen/README.reco, touchscreen/parser.c, touchscreen/reco.c, touchscreen/reco.h, touchscreen/touchscreen.c, touchscreen/touchscreen.h, wifi/compat.c, wifi/compat.h, wifi/wifi.c: New files.
  • Property mode set to 100644
File size: 8.8 KB
Line 
1@---------------------------------------------------------------------------------
2@ DS processor selection
3@---------------------------------------------------------------------------------
4        .arch   armv5te
5        .cpu    arm946e-s
6@---------------------------------------------------------------------------------
7#define PAGE_4K         (0b01011 << 1)
8#define PAGE_8K         (0b01100 << 1)
9#define PAGE_16K        (0b01101 << 1)
10#define PAGE_32K        (0b01110 << 1)
11#define PAGE_64K        (0b00111 << 1)
12#define PAGE_128K       (0b10000 << 1)
13#define PAGE_256K       (0b10001 << 1)
14#define PAGE_512K       (0b10010 << 1)
15#define PAGE_1M         (0b10011 << 1)
16#define PAGE_2M         (0b10100 << 1)
17#define PAGE_4M         (0b10101 << 1)
18#define PAGE_8M         (0b10110 << 1)
19#define PAGE_16M        (0b10111 << 1)
20#define PAGE_32M        (0b11000 << 1)
21#define PAGE_64M        (0b11001 << 1)
22#define PAGE_128M       (0b11010 << 1)
23#define PAGE_256M       (0b11011 << 1)
24#define PAGE_512M       (0b11100 << 1)
25#define PAGE_1G         (0b11101 << 1)
26#define PAGE_2G         (0b11110 << 1)
27#define PAGE_4G         (0b11111 << 1)
28
29#define ITCM_LOAD       (1<<19)
30#define ITCM_ENABLE     (1<<18)
31#define DTCM_LOAD       (1<<17)
32#define DTCM_ENABLE     (1<<16)
33#define DISABLE_TBIT    (1<<15)
34#define ROUND_ROBIN     (1<<14)
35#define ALT_VECTORS     (1<<13)
36#define ICACHE_ENABLE   (1<<12)
37#define BIG_ENDIAN      (1<<7)
38#define DCACHE_ENABLE   (1<<2)
39#define PROTECT_ENABLE  (1<<0)
40
41        .equ    _libnds_argv,0x027FFF70
42
43@---------------------------------------------------------------------------------
44        .section ".init"
45        .global _start
46@---------------------------------------------------------------------------------
47        .align  4
48        .arm
49@---------------------------------------------------------------------------------
50_start:
51@---------------------------------------------------------------------------------
52        mov     r0, #0x04000000                 @ IME = 0;
53        str     r0, [r0, #0x208]
54
55@---------------------------------------------------------------------------------
56@ turn the power on for M3
57@---------------------------------------------------------------------------------
58        ldr     r1, =0x8203
59        add     r0,r0,#0x304
60        strh    r1, [r0]
61
62        ldr     r1, =0x00002078                 @ disable TCM and protection unit
63        mcr     p15, 0, r1, c1, c0
64
65@---------------------------------------------------------------------------------
66@ Protection Unit Setup added by Sasq
67@---------------------------------------------------------------------------------
68        @ Disable cache
69        mov     r0, #0
70        mcr     p15, 0, r0, c7, c5, 0           @ Instruction cache
71        mcr     p15, 0, r0, c7, c6, 0           @ Data cache
72
73        @ Wait for write buffer to empty
74        mcr     p15, 0, r0, c7, c10, 4
75
76        ldr     r0, =__dtcm_start
77        orr     r0,r0,#0x0a
78        mcr     p15, 0, r0, c9, c1,0            @ DTCM base = __dtcm_start, size = 16 KB
79
80        mov r0,#0x20
81        mcr     p15, 0, r0, c9, c1,1            @ ITCM base = 0 , size = 32 MB
82
83@---------------------------------------------------------------------------------
84@ Setup memory regions similar to Release Version
85@---------------------------------------------------------------------------------
86
87        @-------------------------------------------------------------------------
88        @ Region 0 - IO registers
89        @-------------------------------------------------------------------------
90        ldr     r0,=( PAGE_64M | 0x04000000 | 1)
91        mcr     p15, 0, r0, c6, c0, 0
92
93        @-------------------------------------------------------------------------
94        @ Region 1 - Main Memory
95        @-------------------------------------------------------------------------
96        ldr     r0,=( PAGE_4M | 0x02000000 | 1)
97        mcr     p15, 0, r0, c6, c1, 0
98
99        @-------------------------------------------------------------------------
100        @ Region 2 - iwram
101        @-------------------------------------------------------------------------
102        ldr     r0,=( PAGE_32K | 0x037F8000 | 1)
103        mcr     p15, 0, r0, c6, c2, 0
104
105        @-------------------------------------------------------------------------
106        @ Region 3 - DS Accessory (GBA Cart)
107        @-------------------------------------------------------------------------
108        ldr     r0,=( PAGE_128M | 0x08000000 | 1)
109        mcr     p15, 0, r0, c6, c3, 0
110
111        @-------------------------------------------------------------------------
112        @ Region 4 - DTCM
113        @-------------------------------------------------------------------------
114        ldr     r0,=__dtcm_start
115        orr     r0,r0,#(PAGE_16K | 1)
116        mcr     p15, 0, r0, c6, c4, 0
117
118        @-------------------------------------------------------------------------
119        @ Region 5 - ITCM
120        @-------------------------------------------------------------------------
121        ldr     r0,=__itcm_start
122        orr     r0,r0,#(PAGE_32K | 1)
123        mcr     p15, 0, r0, c6, c5, 0
124
125        @-------------------------------------------------------------------------
126        @ Region 6 - System ROM
127        @-------------------------------------------------------------------------
128        ldr     r0,=( PAGE_32K | 0xFFFF0000 | 1)
129        mcr     p15, 0, r0, c6, c6, 0
130
131        @-------------------------------------------------------------------------
132        @ Region 7 - non cacheable main ram
133        @-------------------------------------------------------------------------
134        ldr     r0,=( PAGE_4M  | 0x02400000 | 1)
135        mcr     p15, 0, r0, c6, c7, 0
136
137        @-------------------------------------------------------------------------
138        @ Write buffer enable
139        @-------------------------------------------------------------------------
140        ldr     r0,=0b00000010
141        mcr     p15, 0, r0, c3, c0, 0
142
143        @-------------------------------------------------------------------------
144        @ DCache & ICache enable
145        @-------------------------------------------------------------------------
146        ldr     r0,=0b01000010
147        mcr     p15, 0, r0, c2, c0, 0
148        mcr     p15, 0, r0, c2, c0, 1
149
150        @-------------------------------------------------------------------------
151        @ IAccess
152        @-------------------------------------------------------------------------
153        ldr     r0,=0x36636333
154        mcr     p15, 0, r0, c5, c0, 3
155
156        @-------------------------------------------------------------------------
157        @ DAccess
158        @-------------------------------------------------------------------------
159        ldr     r0,=0x36333333
160        mcr     p15, 0, r0, c5, c0, 2
161
162        @-------------------------------------------------------------------------
163        @ Enable ICache, DCache, ITCM & DTCM
164        @-------------------------------------------------------------------------
165        mrc     p15, 0, r0, c1, c0, 0
166        ldr     r1,= ITCM_ENABLE | DTCM_ENABLE | ICACHE_ENABLE | DCACHE_ENABLE | PROTECT_ENABLE
167        orr     r0,r0,r1
168        mcr     p15, 0, r0, c1, c0, 0
169
170        mov     r0, #0x12               @ Switch to IRQ Mode
171        msr     cpsr, r0
172        ldr     sp, =__sp_irq           @ Set IRQ stack
173
174        mov     r0, #0x1f               @ Switch to SVC Mode
175        msr     cpsr, r0
176        ldr     sp, =__sp_usr           @ Set user stack
177
178        ldr     r1, =__itcm_lma         @ Copy instruction tightly coupled memory (itcm section) from LMA to VMA (ROM to RAM)
179        ldr     r2, =__itcm_start
180        ldr     r4, =__itcm_end
181        bl      CopyMemCheck
182
183        ldr     r1, =__dtcm_lma         @ Copy data tightly coupled memory (dtcm section) from LMA to VMA (ROM to RAM)
184        ldr     r2, =__dtcm_start
185        ldr     r4, =__dtcm_end
186        bl      CopyMemCheck
187
188        ldr     r0, =__bss_start        @ Clear BSS section
189        ldr     r1, =__bss_end
190        sub     r1, r1, r0
191        bl      ClearMem
192
193        ldr     r0, =__sbss_start       @ Clear SBSS section
194        ldr     r1, =__sbss_end
195        sub     r1, r1, r0
196        bl      ClearMem
197
198        ldr     r3, =__libc_init_array  @ global constructors
199        blx     r3
200
201        ldr     r3, =initSystem
202        blx     r3                      @ jump to user code
203
204        mov     r1, #0          @ argv
205        mov     r0, #0          @ argc
206
207
208        ldr     r3, =boot_card
209        blx     r3                      @ jump to user code
210
211        @ If the user ever returns, go back to passme loop
212        ldr     r0, =ILoop
213        ldr     r0, [r0]
214        ldr     r1, =0x027FFE78
215        str     r0, [r1]
216        bx      r1
217ILoop:
218        b       ILoop
219
220
221@---------------------------------------------------------------------------------
222@ Clear memory to 0x00 if length != 0
223@  r0 = Start Address
224@  r1 = Length
225@---------------------------------------------------------------------------------
226ClearMem:
227@---------------------------------------------------------------------------------
228        mov     r2, #3                  @ Round down to nearest word boundary
229        add     r1, r1, r2              @ Shouldn't be needed
230        bics    r1, r1, r2              @ Clear 2 LSB (and set Z)
231        bxeq    lr                      @ Quit if copy size is 0
232
233        mov     r2, #0
234ClrLoop:
235        stmia   r0!, {r2}
236        subs    r1, r1, #4
237        bne     ClrLoop
238
239        bx      lr
240
241@---------------------------------------------------------------------------------
242@ Copy memory if length != 0
243@  r1 = Source Address
244@  r2 = Dest Address
245@  r4 = Dest Address + Length
246@---------------------------------------------------------------------------------
247CopyMemCheck:
248@---------------------------------------------------------------------------------
249        sub     r3, r4, r2              @ Is there any data to copy?
250@---------------------------------------------------------------------------------
251@ Copy memory
252@  r1 = Source Address
253@  r2 = Dest Address
254@  r3 = Length
255@---------------------------------------------------------------------------------
256CopyMem:
257@---------------------------------------------------------------------------------
258        mov     r0, #3                  @ These commands are used in cases where
259        add     r3, r3, r0              @ the length is not a multiple of 4,
260        bics    r3, r3, r0              @ even though it should be.
261        bxeq    lr                      @ Length is zero, so exit
262CIDLoop:
263        ldmia   r1!, {r0}
264        stmia   r2!, {r0}
265        subs    r3, r3, #4
266        bne     CIDLoop
267
268        bx      lr
269
270
271        .global SWI_Handler
272        .global do_data_abort
273SWI_Handler:
274do_data_abort:
275        mov pc, lr
276
277@---------------------------------------------------------------------------------
278        .align
279        .pool
280        .end
281@---------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.