Files
atomthreads/ports/armv7a/arm_entry.S
Anup Patel f36452df66 Adding file to armv7a directory.
Signed-off-by: Anup Patel <anup@brainfault.org>
2011-07-07 17:37:12 +05:30

152 lines
4.5 KiB
ArmAsm

/*
* Copyright (c) 2011, Anup Patel. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. No personal names or organizations' names associated with the
* Atomthreads project may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE ATOMTHREADS PROJECT AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <arm_asm_macro.h>
.section .expvect, "ax", %progbits
.globl _start_vect
_start_vect:
ldr pc, __reset
ldr pc, __undefined_instruction
ldr pc, __software_interrupt
ldr pc, __prefetch_abort
ldr pc, __data_abort
ldr pc, __not_used
ldr pc, __irq
ldr pc, __fiq
__reset:
.word _reset
__undefined_instruction:
.word _undefined_instruction
__software_interrupt:
.word _software_interrupt
__prefetch_abort:
.word _prefetch_abort
__data_abort:
.word _data_abort
__not_used:
.word _not_used
__irq:
.word _irq
__fiq:
.word _fiq
.global _end_vect
_end_vect:
__initial_stack_end:
.word _initial_stack_end
.globl _reset
_reset:
/* Clear a register for temporary usage */
mov r8, #0
/* Disable IRQ & FIQ */
cpsid if
/* Set Supervisor Mode Stack */
SET_CURRENT_MODE CPSR_MODE_SUPERVISOR
SET_CURRENT_STACK __initial_stack_end
/* Set Undefined Mode Stack */
SET_CURRENT_MODE CPSR_MODE_UNDEFINED
SET_CURRENT_STACK __initial_stack_end
/* Set Abort Mode Stack */
SET_CURRENT_MODE CPSR_MODE_ABORT
SET_CURRENT_STACK __initial_stack_end
/* Set IRQ Mode Stack */
SET_CURRENT_MODE CPSR_MODE_IRQ
SET_CURRENT_STACK __initial_stack_end
/* Set FIQ Mode Stack */
SET_CURRENT_MODE CPSR_MODE_FIQ
SET_CURRENT_STACK __initial_stack_end
/* Set System Mode Stack */
SET_CURRENT_MODE CPSR_MODE_SYSTEM
SET_CURRENT_STACK __initial_stack_end
/* Set to Supervisor Mode */
SET_CURRENT_MODE CPSR_MODE_SUPERVISOR
/* Call main function */
bl main
/* We should never reach here */
b .
START_EXCEPTION_HANDLER _undefined_instruction, 4
PUSH_USER_REGS
PUSH_BANKED_REGS _undefined_instruction_bankpush_skip
CALL_EXCEPTION_CFUNC do_undefined_instruction
PULL_BANKED_REGS _undefined_instruction_bankpull_skip
PULL_USER_REGS
END_EXCEPTION_HANDLER
START_EXCEPTION_HANDLER _software_interrupt, 4
PUSH_USER_REGS
PUSH_BANKED_REGS _software_interrupt_bankpush_skip
CALL_EXCEPTION_CFUNC do_software_interrupt
PULL_BANKED_REGS _software_interrupt_bankpull_skip
PULL_USER_REGS
END_EXCEPTION_HANDLER
START_EXCEPTION_HANDLER _prefetch_abort, 4
PUSH_USER_REGS
PUSH_BANKED_REGS _prefetch_abort_bankpush_skip
CALL_EXCEPTION_CFUNC do_prefetch_abort
PULL_BANKED_REGS _prefetch_abort_bankpull_skip
PULL_USER_REGS
END_EXCEPTION_HANDLER
START_EXCEPTION_HANDLER _data_abort, 8
PUSH_USER_REGS
PUSH_BANKED_REGS _data_abort_bankpush_skip
CALL_EXCEPTION_CFUNC do_data_abort
PULL_BANKED_REGS _data_abort_bankpull_skip
PULL_USER_REGS
END_EXCEPTION_HANDLER
START_EXCEPTION_HANDLER _not_used, 4
PUSH_USER_REGS
PUSH_BANKED_REGS _not_used_bankpush_skip
CALL_EXCEPTION_CFUNC do_not_used
PULL_BANKED_REGS _not_used_bankpull_skip
PULL_USER_REGS
END_EXCEPTION_HANDLER
START_EXCEPTION_HANDLER _irq, 4
PUSH_USER_REGS
PUSH_BANKED_REGS _irq_bankpush_skip
CALL_EXCEPTION_CFUNC do_irq
PULL_BANKED_REGS _irq_bankpull_skip
PULL_USER_REGS
END_EXCEPTION_HANDLER
START_EXCEPTION_HANDLER _fiq, 4
PUSH_USER_REGS
PUSH_BANKED_REGS _fiq_bankpush_skip
CALL_EXCEPTION_CFUNC do_fiq
PULL_BANKED_REGS _fiq_bankpull_skip
PULL_USER_REGS
END_EXCEPTION_HANDLER