2016-07-05 16:05:53 +02:00
|
|
|
@ This file is part of Luma3DS
|
2017-06-05 02:02:04 +02:00
|
|
|
@ Copyright (C) 2016-2017 Aurora Wright, TuxSH
|
2016-07-05 16:05:53 +02:00
|
|
|
@
|
|
|
|
@ This program is free software: you can redistribute it and/or modify
|
|
|
|
@ it under the terms of the GNU General Public License as published by
|
|
|
|
@ the Free Software Foundation, either version 3 of the License, or
|
|
|
|
@ (at your option) any later version.
|
|
|
|
@
|
|
|
|
@ This program is distributed in the hope that it will be useful,
|
|
|
|
@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
@ GNU General Public License for more details.
|
|
|
|
@
|
|
|
|
@ You should have received a copy of the GNU General Public License
|
|
|
|
@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
@
|
2017-06-05 02:02:04 +02:00
|
|
|
@ Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
|
|
|
@ * Requiring preservation of specified reasonable legal notices or
|
|
|
|
@ author attributions in that material or in the Appropriate Legal
|
|
|
|
@ Notices displayed by works containing it.
|
|
|
|
@ * Prohibiting misrepresentation of the origin of that material,
|
|
|
|
@ or requiring that modified versions of such material be marked in
|
|
|
|
@ reasonable ways as different from the original version.
|
2016-07-05 16:05:53 +02:00
|
|
|
|
2015-08-05 03:57:37 +02:00
|
|
|
.section .text.start
|
|
|
|
.align 4
|
|
|
|
.global _start
|
|
|
|
_start:
|
2017-05-24 19:52:09 +02:00
|
|
|
@ Disable interrupts and switch to supervisor mode (also clear flags)
|
|
|
|
mov r4, #0x13
|
2017-05-18 01:05:56 +02:00
|
|
|
orr r4, #0x1C0
|
2017-05-24 19:52:09 +02:00
|
|
|
msr cpsr_cxsf, r4
|
2017-05-18 01:05:56 +02:00
|
|
|
|
2017-05-19 21:56:20 +02:00
|
|
|
mov r9, r0
|
|
|
|
mov r10, r1
|
2017-05-23 16:11:39 +02:00
|
|
|
mov r11, r2
|
2017-05-19 21:56:20 +02:00
|
|
|
|
2016-10-12 04:46:33 +02:00
|
|
|
@ Change the stack pointer
|
2017-05-23 02:44:04 +02:00
|
|
|
mov sp, #0x08100000
|
2016-10-12 04:46:33 +02:00
|
|
|
|
2016-07-01 20:27:28 +02:00
|
|
|
@ Disable caches / MPU
|
2017-05-18 01:05:56 +02:00
|
|
|
mrc p15, 0, r4, c1, c0, 0 @ read control register
|
2017-05-24 19:52:09 +02:00
|
|
|
bic r4, #(1<<16) @ - DTCM disable
|
2017-05-18 01:05:56 +02:00
|
|
|
bic r4, #(1<<12) @ - instruction cache disable
|
|
|
|
bic r4, #(1<<2) @ - data cache disable
|
2017-05-24 19:52:09 +02:00
|
|
|
bic r4, #(1<<0) @ - MPU disable
|
2017-05-18 01:05:56 +02:00
|
|
|
mcr p15, 0, r4, c1, c0, 0 @ write control register
|
2016-07-01 20:27:28 +02:00
|
|
|
|
2017-05-24 19:52:09 +02:00
|
|
|
@ Invalidate both caches, discarding any data they may contain,
|
|
|
|
@ then drain the write buffer
|
|
|
|
mov r4, #0
|
|
|
|
mcr p15, 0, r4, c7, c5, 0
|
|
|
|
mcr p15, 0, r4, c7, c6, 0
|
|
|
|
mcr p15, 0, r4, c7, c10, 4
|
2016-07-01 20:27:28 +02:00
|
|
|
|
2016-02-25 20:19:20 +01:00
|
|
|
@ Give read/write access to all the memory regions
|
2017-05-24 19:52:09 +02:00
|
|
|
ldr r0, =0x33333333
|
2016-06-05 20:43:49 +02:00
|
|
|
mcr p15, 0, r0, c5, c0, 2 @ write data access
|
|
|
|
mcr p15, 0, r0, c5, c0, 3 @ write instruction access
|
2016-05-28 23:47:30 +02:00
|
|
|
|
2016-07-01 20:27:28 +02:00
|
|
|
@ Set MPU permissions and cache settings
|
2016-07-02 10:59:21 +02:00
|
|
|
ldr r0, =0xFFFF001D @ ffff0000 32k | bootrom (unprotected part)
|
2017-06-05 02:02:04 +02:00
|
|
|
ldr r1, =0xFFF0001B @ fff00000 16k | dtcm
|
2017-05-24 19:52:09 +02:00
|
|
|
ldr r2, =0x01FF801D @ 01ff8000 32k | itcm
|
2017-05-26 18:17:40 +02:00
|
|
|
ldr r3, =0x08000027 @ 08000000 1M | arm9 mem
|
2017-05-24 19:52:09 +02:00
|
|
|
ldr r4, =0x10000029 @ 10000000 2M | io mem (ARM9 / first 2MB)
|
2017-05-26 18:17:40 +02:00
|
|
|
ldr r5, =0x20000035 @ 20000000 128M | fcram
|
2017-05-24 19:52:09 +02:00
|
|
|
ldr r6, =0x1FF00027 @ 1FF00000 1M | dsp / axi wram
|
|
|
|
ldr r7, =0x1800002D @ 18000000 8M | vram (+ 2MB)
|
|
|
|
mov r8, #0x29
|
2016-02-25 20:19:20 +01:00
|
|
|
mcr p15, 0, r0, c6, c0, 0
|
|
|
|
mcr p15, 0, r1, c6, c1, 0
|
|
|
|
mcr p15, 0, r2, c6, c2, 0
|
|
|
|
mcr p15, 0, r3, c6, c3, 0
|
|
|
|
mcr p15, 0, r4, c6, c4, 0
|
|
|
|
mcr p15, 0, r5, c6, c5, 0
|
|
|
|
mcr p15, 0, r6, c6, c6, 0
|
|
|
|
mcr p15, 0, r7, c6, c7, 0
|
2017-05-24 19:52:09 +02:00
|
|
|
mcr p15, 0, r8, c3, c0, 0 @ Write bufferable 0, 3, 5
|
|
|
|
mcr p15, 0, r8, c2, c0, 0 @ Data cacheable 0, 3, 5
|
|
|
|
mcr p15, 0, r8, c2, c0, 1 @ Inst cacheable 0, 3, 5
|
|
|
|
|
|
|
|
@ Set DTCM address and size to the default values
|
2017-05-25 03:06:16 +02:00
|
|
|
ldr r1, =0xFFF0000A @ set DTCM address and size
|
2017-05-24 19:52:09 +02:00
|
|
|
mcr p15, 0, r1, c9, c1, 0 @ set the dtcm Region Register
|
2016-02-25 20:19:20 +01:00
|
|
|
|
2016-08-14 12:30:12 +02:00
|
|
|
@ Enable caches / MPU / ITCM
|
2016-06-05 20:43:49 +02:00
|
|
|
mrc p15, 0, r0, c1, c0, 0 @ read control register
|
2016-08-14 12:30:12 +02:00
|
|
|
orr r0, r0, #(1<<18) @ - ITCM enable
|
2017-05-24 19:52:09 +02:00
|
|
|
orr r0, r0, #(1<<16) @ - DTCM enable
|
2016-08-13 15:31:08 +02:00
|
|
|
orr r0, r0, #(1<<13) @ - alternate exception vectors enable
|
2016-06-05 20:43:49 +02:00
|
|
|
orr r0, r0, #(1<<12) @ - instruction cache enable
|
|
|
|
orr r0, r0, #(1<<2) @ - data cache enable
|
2017-05-24 19:52:09 +02:00
|
|
|
orr r0, r0, #(1<<0) @ - MPU enable
|
2016-06-05 20:43:49 +02:00
|
|
|
mcr p15, 0, r0, c1, c0, 0 @ write control register
|
2015-08-05 03:57:37 +02:00
|
|
|
|
2017-06-05 02:02:04 +02:00
|
|
|
@ Fix mounting of SDMC
|
|
|
|
ldr r0, =0x10000020
|
|
|
|
mov r1, #0x340
|
|
|
|
str r1, [r0]
|
|
|
|
|
2017-04-17 03:59:45 +02:00
|
|
|
@ Clear BSS
|
2017-02-23 19:30:09 +01:00
|
|
|
ldr r0, =__bss_start
|
|
|
|
mov r1, #0
|
|
|
|
ldr r2, =__bss_end
|
|
|
|
sub r2, r0
|
|
|
|
bl memset32
|
|
|
|
|
2017-05-19 21:56:20 +02:00
|
|
|
mov r0, r9
|
|
|
|
mov r1, r10
|
2017-05-23 16:11:39 +02:00
|
|
|
mov r2, r11
|
2016-04-02 17:58:06 +02:00
|
|
|
b main
|