1 # EPIPHANY implementation of wrappers over user C ISR ()
3 # Copyright (c) 2011, Adapteva, Inc.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions are met:
8 # * Redistributions of source code must retain the above copyright notice,
9 # this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
13 # * Neither the name of Adapteva nor the names of its contributors may be
14 # used to endorse or promote products derived from this software without
15 # specific prior written permission.
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 # POSSIBILITY OF SUCH DAMAGE.
29 .section RESERVED_CRT0,"a",@progbits ;
30 .set sw_exception_v_n, 1
32 .set timer0_expired_v_n, 3;
33 .set timer1_expired_v_n, 4;
40 // preserve isr-mods to ACTIVE, GID, KERNEL, WAND, & EXCAUSE bits in the status reg
41 .set status_mask, 0x0007000f;
42 // for the wand isr, preserve isr-mods to ACTIVE, GID, KERNEL, & EXCAUSE, but
43 // clear the WAND bit.
44 .set wand_status_mask, 0x00070007;
48 .global _DEFAULT_ISR_CALLBACK;
50 .type _DEFAULT_ISR_CALLBACK, %function
51 _DEFAULT_ISR_CALLBACK:
53 .size _DEFAULT_ISR_CALLBACK, .-_DEFAULT_ISR_CALLBACK
56 .global _DEFAULT_ISR_CALLBACK_FOR_sw_exception_v;
58 .type _DEFAULT_ISR_CALLBACK_FOR_sw_exception_v, %function
59 _DEFAULT_ISR_CALLBACK_FOR_sw_exception_v:
61 .size _DEFAULT_ISR_CALLBACK_FOR_sw_exception_v, .-_DEFAULT_ISR_CALLBACK_FOR_sw_exception_v
64 .set NUMBER_ENTRIES_IN_IVT, 8
67 .type _ISR_VECTOR, %object
69 .word _DEFAULT_ISR_CALLBACK_FOR_sw_exception_v; reset
70 .word _DEFAULT_ISR_CALLBACK_FOR_sw_exception_v; sw_exception
71 .word _DEFAULT_ISR_CALLBACK_FOR_sw_exception_v; page_miss
72 .rept NUMBER_ENTRIES_IN_IVT
73 .word _DEFAULT_ISR_CALLBACK
75 .size _ISR_VECTOR, .-_ISR_VECTOR
77 .macro IVT_ENTRY_CALL entry_v_
78 ;; assuming we have valid frame poiter
84 .if \entry_v_ == wand_v_n
85 mov r1, %low(wand_status_mask) ; this mask will exclude WAND, so it will
86 movt r1, %high(wand_status_mask) ; be forcibly cleared
88 mov r1, %low(status_mask)
89 movt r1, %high(status_mask)
91 str r1, [sp,0x9] ; save the status register isr-preserve mask on the stack
97 .type __dispatcher, %function
113 mov r1, %low(_ISR_VECTOR)
115 ldr r1, [r2,0] ;; r1 = _ISR_VECTOR[entry_v]
117 add r0, r0, r2 ;; r0 = signum
124 // preserve isr-modifications to some of the bits in the status register,
125 // but restore the rest to pre-interrupt values.
126 // status = (status[post_isr] & status_mask) | (status[pre_isr] & ~status_mask)
128 ldr.l r2, [sp, 9] ; fetch the status register isr preserve mask from the stack
130 and r1, r1, r2; (status[post_isr] & status_mask)
133 mov r2, %low(~status_mask)
134 movt r2, %high(~status_mask)
135 and r0, r0, r2; (status[pre_isr] & ~status_mask)
137 orr r0, r0, r1 ; combine pre_isr & post_isr status bits
151 .size __dispatcher, .-__dispatcher
154 .global .sw_exception_v;
155 .type .sw_exception_v, %function
157 IVT_ENTRY_CALL sw_exception_v_n;
158 .size .sw_exception_v, .-.sw_exception_v
160 .global .page_miss_v;
161 .type .page_miss_v, %function
163 IVT_ENTRY_CALL page_miss_v_n;
164 .size .page_miss_v, .-.page_miss_v
166 .global .timer0_expired_v;
168 IVT_ENTRY_CALL timer0_expired_v_n;
170 .global .timer1_expired_v;
172 IVT_ENTRY_CALL timer1_expired_v_n;
176 IVT_ENTRY_CALL message_v_n;
180 IVT_ENTRY_CALL dma0_v_n;
184 IVT_ENTRY_CALL dma1_v_n;
188 IVT_ENTRY_CALL wand_v_n;
192 IVT_ENTRY_CALL soft_v_n;