jacking/rpi/vectors.s

114 lines
2.7 KiB
ArmAsm

@ vim: set ft=armv5:
.section ".entry", "awx", %progbits
.global VECTORS
VECTORS:
ldr pc, reset_handler
ldr pc, undefined_handler
ldr pc, swi_handler
ldr pc, prefetch_handler
ldr pc, data_handler
ldr pc, unused_handler
ldr pc, irq_handler
ldr pc, fiq_handler
reset_handler:
.4byte _start
undefined_handler:
.4byte hang
swi_handler:
.4byte hang
prefetch_handler:
.4byte hang
data_handler:
.4byte hang
unused_handler:
.4byte hang
irq_handler:
.4byte hang
fiq_handler:
.4byte hang
.global _start
_start:
@ copy over exception vectors
mov r0, #0x8000
mov r1, #0
ldmia r0!, {r2-r9}
stmia r1!, {r2-r9}
ldmia r0!, {r2-r9}
stmia r1!, {r2-r9}
@ IRQ mode
mov r0, #0xd2
msr cpsr_c, r0
mov sp, #0x8000
@ FIQ mode
mov r0, #0xd1
msr cpsr_c, r0
mov sp, #0x4000
@ SVC mode
mov r0, #0xd3
msr cpsr_c, r0
mov sp, #0x08000000
mov r0, #0
mcr p15, 0, r0, c3, c0, 0 @ disable write buffer
mcr p15, 0, r0, c2, c0, 0 @ disable icache & dcache
mcr p15, 0, r0, c2, c0, 1
@ disable stuff
mrc p15, 0, r0, c1, c0, 0
ldr r1, =((1<<12)|(1<<2)|(1<<0)) @ icache/dcache/mpu enable bits
bic r0, r1
mcr p15, 0, r0, c1, c0, 0
@ clear bss
ldr r0, =__bss_start
ldr r1, =__bss_end
mov r2, #0
mov r3, #0
zeroloop:
strd r2, r3, [r0], #8
cmp r0, r1
bne zeroloop
bl main
@ fallthru
hang:
b hang
.pool
/*.section ".text.utils", "ax", %progbits
.global PUT32
PUT32:
str r1,[r0]
bx lr
.global GET32
GET32:
ldr r0,[r0]
;@ bx lr
.global dummy
dummy:
bx lr*/
;@-------------------------------------------------------------------------
;@
;@ Copyright (c) 2012 David Welch dwelch@dwelch.com
;@
;@ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
;@
;@ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
;@
;@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
;@
;@-------------------------------------------------------------------------