Rev 312 | Blame | Last modification | View Log | RSS feed
@@@ Copyright 2010 TheSeven@@@ This file is part of emBIOS.@@ emBIOS 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 2 of the@ License, or (at your option) any later version.@@ emBIOS 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 emBIOS. If not, see <http://www.gnu.org/licenses/>.@@.section .intvect,"ax",%progbitsldr pc, =reset_handlerldr pc, =undef_instr_handlerldr pc, =syscall_handlerldr pc, =prefetch_abort_handlerldr pc, =data_abort_handlerldr pc, =reserved_handlerldr pc, =irq_handlerldr pc, =fiq_handler.ltorg.section .inithead,"ax",%progbits.global __start__start:b _start.section .initcode,"ax",%progbits.global _start_start:mrc p15, 0, r0,c1,c0orr r0, r0, #5mcr p15, 0, r0,c1,c0ldr r0, =_sramsourceldr r1, =_sramstartldr r2, =_sramend.copysram:cmp r2, r1ldrhi r3, [r0], #4strhi r3, [r1], #4bhi .copysramldr r0, =_sdramsourceldr r1, =_sdramstartldr r2, =_sdramend.copysdram:cmp r2, r1ldrhi r3, [r0], #4strhi r3, [r1], #4bhi .copysdramldr r0, =_initbssstartldr r1, =_initbssendmov r2, #0.clearinitbss:cmp r1, r0strhi r2, [r0], #4bhi .clearinitbssldr r0, =_ibssstartldr r1, =_ibssend.clearibss:cmp r1, r0strhi r2, [r0], #4bhi .clearibssldr r0, =_bssstartldr r1, =_bssend.clearbss:cmp r1, r0strhi r2, [r0], #4bhi .clearbssldr r1, =0x38200000ldr r0, [r1]orr r0, r0, #1bic r0, r0, #0x10000str r0, [r1]mov r0, #0.cleancache:mcr p15, 0, r0,c7,c10,2add r1, r0, #0x10mcr p15, 0, r1,c7,c10,2add r1, r1, #0x10mcr p15, 0, r1,c7,c10,2add r1, r1, #0x10mcr p15, 0, r1,c7,c10,2adds r0, r0, #0x04000000bne .cleancachemcr p15, 0, r0,c7,c10,4mcr p15, 0, r0,c7,c5,0mov r1, #0x39c00000str r0, [r1,#4]str r0, [r1,#8]str r0, [r1,#0x38]str r0, [r1,#0x20]sub r0, r0, #1str r0, [r1]str r0, [r1,#0x10]str r0, [r1,#0x1c]msr cpsr_c, #0xd2ldr sp, =_irqstackendmsr cpsr_c, #0xd7ldr sp, =_abortstackendmsr cpsr_c, #0xdbldr sp, =_abortstackendmsr cpsr_c, #0x1fldr sp, =_initstackendbl initbl context_switchmov r0, #0ldr pc, =idleloop.ltorg.section .icode, "ax", %progbits.align 2idleloop:mcr p15, 0, r0,c7,c0,4b idleloop.global reset.global hang.type reset, %function.type hang, %functionreset:msr cpsr_c, #0xd3mov r0, #0x110000add r0, r0, #0xffadd r1, r0, #0xa00mov r2, #0x3c800000str r1, [r2]mov r1, #0xff0str r1, [r2,#4]str r0, [r2]hang:msr cpsr_c, #0xd3mcr p15, 0, r0,c7,c0,4b hang.size reset, .-reset.size hang, .-hang.type reset_handler, %functionreset_handler:mov r0, #0adr r1, reset_textb panicreset_text:.ascii "Hit reset vector!\0".size reset_handler, .-reset_handler.type undef_instr_handler, %functionundef_instr_handler:mov r0, #0adr r1, undef_instr_textsub r2, lr, #4b panicf.size undef_instr_handler, .-undef_instr_handler.type prefetch_abort_handler, %functionprefetch_abort_handler:mov r0, #0adr r1, prefetch_abort_textsub r2, lr, #4b panicf.size prefetch_abort_handler, .-prefetch_abort_handler.type data_abort_handler, %functiondata_abort_handler:mov r0, #0adr r1, data_abort_textsub r2, lr, #4b panicf.size data_abort_handler, .-data_abort_handler.type reserved_handler, %functionreserved_handler:mov r0, #0adr r1, reserved_textb panic.size reserved_handler, .-reserved_handler.type fiq_handler, %functionfiq_handler:mov r0, #2adr r1, fiq_textb panic.size fiq_handler, .-fiq_handlerundef_instr_text:.ascii "Undefined instruction at %08X!\0"prefetch_abort_text:.ascii "Prefetch abort at %08X!\0"data_abort_text:.ascii "Data abort at %08X!\0"reserved_text:.ascii "Hit reserved exception handler!\0"fiq_text:.ascii "Unhandled FIQ!\0"syscall_text:.ascii "Unhandled syscall!\0".section .icode.usec_timer, "ax", %progbits.align 2.global read_native_timer.type read_native_timer, %functionread_native_timer:ldr r0, val_3c700000ldr r1, [r0,#0x80]ldr r0, [r0,#0x84]bx lr.size read_native_timer, .-read_native_timer.global read_usec_timer.type read_usec_timer, %functionread_usec_timer:ldr r0, val_3c700000ldr r1, [r0,#0x80]ldr r0, [r0,#0x84]add r0, r0, r0,lsl#2bx lr.size read_usec_timer, .-read_usec_timerval_3c700000:.word 0x3c700000.section .text.control_nor_cache, "ax", %progbits.align 2.global control_nor_cache.type control_nor_cache, %functioncontrol_nor_cache:mrc p15, 0, r3,c1,c0bic r1, r3, #1mcr p15, 0, r1,c1,c0mov r1, #0mcr p15, 0, r1,c7,c5cnc_flushcache_loop:mcr p15, 0, r1,c7,c14,2add r2, r1, #0x10mcr p15, 0, r2,c7,c14,2add r2, r2, #0x10mcr p15, 0, r2,c7,c14,2add r2, r2, #0x10mcr p15, 0, r2,c7,c14,2adds r1, r1, #0x04000000bne cnc_flushcache_loopmcr p15, 0, r1,c7,c10,4ands r0, r0, r0mrc p15, 0, r1,c2,c0, 1biceq r1, r1, #0x10orrne r1, r1, #0x10mcr p15, 0, r1,c2,c0, 1mrc p15, 0, r1,c2,c0, 0biceq r1, r1, #0x10orrne r1, r1, #0x10mcr p15, 0, r1,c2,c0, 0mrc p15, 0, r1,c3,c0, 0biceq r1, r1, #0x10orrne r1, r1, #0x10mcr p15, 0, r1,c3,c0, 0mcr p15, 0, r3,c1,c0mov pc, lr.size control_nor_cache, .-control_nor_cache