2013-03-04 05:52:05 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the libpayload project.
|
|
|
|
*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* 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. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
|
|
|
*/
|
|
|
|
|
2014-01-25 01:23:08 +01:00
|
|
|
.text
|
2013-03-04 05:52:05 +01:00
|
|
|
|
|
|
|
.align 6
|
|
|
|
.arm
|
|
|
|
.global exception_table
|
|
|
|
exception_table:
|
|
|
|
b 1f
|
|
|
|
b 2f
|
|
|
|
b 3f
|
|
|
|
b 4f
|
|
|
|
b 5f
|
|
|
|
b 6f
|
|
|
|
b 7f
|
|
|
|
b 8f
|
|
|
|
|
|
|
|
1:
|
2013-12-11 09:23:15 +01:00
|
|
|
mov sp, $0
|
2013-03-04 05:52:05 +01:00
|
|
|
b exception_common
|
2014-05-14 23:53:18 +02:00
|
|
|
|
|
|
|
/* Undefined Instruction (CAREFUL: the PC offset is specific to thumb mode!) */
|
2013-03-04 05:52:05 +01:00
|
|
|
2:
|
2014-05-14 23:53:18 +02:00
|
|
|
sub lr, lr, $2
|
2013-12-11 09:23:15 +01:00
|
|
|
mov sp, $1
|
2013-03-04 05:52:05 +01:00
|
|
|
b exception_common
|
2014-05-14 23:53:18 +02:00
|
|
|
|
|
|
|
/* Software Interrupt (no PC offset necessary) */
|
2013-03-04 05:52:05 +01:00
|
|
|
3:
|
2013-12-11 09:23:15 +01:00
|
|
|
mov sp, $2
|
2013-03-04 05:52:05 +01:00
|
|
|
b exception_common
|
2014-05-14 23:53:18 +02:00
|
|
|
|
|
|
|
/* Prefetch Abort */
|
2013-03-04 05:52:05 +01:00
|
|
|
4:
|
2014-05-14 23:53:18 +02:00
|
|
|
sub lr, lr, $4
|
2013-12-11 09:23:15 +01:00
|
|
|
mov sp, $3
|
2013-03-04 05:52:05 +01:00
|
|
|
b exception_common
|
2014-05-14 23:53:18 +02:00
|
|
|
|
|
|
|
/* Data Abort */
|
2013-03-04 05:52:05 +01:00
|
|
|
5:
|
2014-05-14 23:53:18 +02:00
|
|
|
sub lr, lr, $8
|
2013-12-11 09:23:15 +01:00
|
|
|
mov sp, $4
|
2013-03-04 05:52:05 +01:00
|
|
|
b exception_common
|
2014-05-14 23:53:18 +02:00
|
|
|
|
|
|
|
/* (not used) */
|
2013-03-04 05:52:05 +01:00
|
|
|
6:
|
2013-12-11 09:23:15 +01:00
|
|
|
mov sp, $5
|
2013-03-04 05:52:05 +01:00
|
|
|
b exception_common
|
2014-05-14 23:53:18 +02:00
|
|
|
|
|
|
|
/* Interrupt */
|
2013-03-04 05:52:05 +01:00
|
|
|
7:
|
2014-05-14 23:53:18 +02:00
|
|
|
sub lr, lr, $4
|
2013-12-11 09:23:15 +01:00
|
|
|
mov sp, $6
|
2013-03-04 05:52:05 +01:00
|
|
|
b exception_common
|
2014-05-14 23:53:18 +02:00
|
|
|
|
|
|
|
/* Fast Interrupt */
|
2013-03-04 05:52:05 +01:00
|
|
|
8:
|
2014-05-14 23:53:18 +02:00
|
|
|
sub lr, lr, $4
|
2013-12-11 09:23:15 +01:00
|
|
|
mov sp, $7
|
2013-03-04 05:52:05 +01:00
|
|
|
b exception_common
|
|
|
|
|
|
|
|
exception_common:
|
2013-12-11 09:23:15 +01:00
|
|
|
str sp, exception_idx
|
2013-03-04 05:52:05 +01:00
|
|
|
ldr sp, exception_stack_end
|
|
|
|
push { lr }
|
2013-09-18 23:39:50 +02:00
|
|
|
stmfd sp, { sp, lr }^
|
2013-03-04 05:52:05 +01:00
|
|
|
sub sp, sp, $8
|
|
|
|
push { r0 - r12 }
|
2013-12-16 13:07:50 +01:00
|
|
|
mrs r0, SPSR
|
|
|
|
push { r0 }
|
2013-03-04 05:52:05 +01:00
|
|
|
mov r0, sp
|
2013-12-11 09:23:15 +01:00
|
|
|
ldr r1, exception_idx
|
|
|
|
blx exception_dispatch
|
2013-12-16 13:07:50 +01:00
|
|
|
pop { r0 }
|
|
|
|
msr SPSR_cxsf, r0
|
2013-03-04 05:52:05 +01:00
|
|
|
pop { r0 - r12 }
|
|
|
|
add sp, sp, $8
|
2013-09-18 23:39:50 +02:00
|
|
|
ldmfd sp!, { pc }^
|
2013-03-04 05:52:05 +01:00
|
|
|
|
|
|
|
|
2014-01-25 01:23:08 +01:00
|
|
|
.align 2
|
|
|
|
.global exception_stack_end
|
|
|
|
exception_stack_end:
|
|
|
|
.word 0
|
|
|
|
|
2013-12-11 09:23:15 +01:00
|
|
|
exception_idx:
|
2014-01-25 01:23:08 +01:00
|
|
|
.word 0
|
|
|
|
|
2013-03-04 05:52:05 +01:00
|
|
|
.thumb
|
|
|
|
.global set_vbar
|
|
|
|
.thumb_func
|
|
|
|
set_vbar:
|
|
|
|
mcr p15, 0, r0, c12, c0, 0
|
|
|
|
bx lr
|
|
|
|
|