Search
lxdream.org :: lxdream/test/interrupt.s :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename test/interrupt.s
changeset 228:70adc8ffa8d1
next233:f8333b94f503
author nkeynes
date Mon Sep 25 11:13:56 2006 +0000 (14 years ago)
permissions -rw-r--r--
last change Commit BF tests and initial exception handler
file annotate diff log raw
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/test/interrupt.s Mon Sep 25 11:13:56 2006 +0000
1.3 @@ -0,0 +1,247 @@
1.4 +.section .text
1.5 +.include "sh4/inc.s"
1.6 +
1.7 +! expect_interrupt( int intevt )
1.8 +.global _expect_interrupt
1.9 +_expect_interrupt:
1.10 + stc sr, r3 ! Mask off interrupts
1.11 + mov.l bl_mask, r0
1.12 + or r3, r0
1.13 + ldc r0, sr
1.14 + mova expected_intevt, r0
1.15 + mov.l r4, @r0
1.16 + xor r1, r1
1.17 + mova expected_expevt, r0
1.18 + mov.l r1, @r0
1.19 + mova _interrupt_count, r0
1.20 + mov.l r1, @r0
1.21 + mova _interrupt_pc, r0
1.22 + mov.l r1, @r0
1.23 + ldc r3, sr ! Restore old SR state
1.24 + rts
1.25 + nop
1.26 +
1.27 + .global _expect_exception
1.28 +_expect_exception:
1.29 + stc sr, r3 ! Mask off interrupts
1.30 + mov.l bl_mask, r0
1.31 + or r3, r0
1.32 + ldc r0, sr
1.33 + mova expected_expevt, r0
1.34 + mov.l r4, @r0
1.35 + xor r1, r1
1.36 + mova expected_intevt, r0
1.37 + mov.l r1, @r0
1.38 + mova _interrupt_count, r0
1.39 + mov.l r1, @r0
1.40 + mova _interrupt_pc, r0
1.41 + mov.l r1, @r0
1.42 + ldc r3, sr ! Restore old SR state
1.43 + rts
1.44 + nop
1.45 +
1.46 + .align 4
1.47 +.global _interrupt_count
1.48 +_interrupt_count:
1.49 + .long 0x00000000
1.50 +.global _interrupt_pc
1.51 +_interrupt_pc:
1.52 + .long 0x00000000
1.53 +bl_mask:
1.54 + .long 0x10000000
1.55 +
1.56 +.global _install_interrupt_handler
1.57 +_install_interrupt_handler:
1.58 + stc vbr, r1
1.59 + mova old_vbr, r0
1.60 + mov.l r1, @r0
1.61 + mova __interrupt_handler, r0
1.62 + ldc r0, vbr
1.63 + rts
1.64 + nop
1.65 +
1.66 +.global _remove_interrupt_handler
1.67 +_remove_interrupt_handler:
1.68 + mov.l old_vbr, r1
1.69 + ldc r1, vbr
1.70 + rts
1.71 + nop
1.72 +.align 4
1.73 +old_vbr:
1.74 + .long 0x00000000
1.75 +expected_intevt:
1.76 + .long 0x00000000
1.77 +expected_expevt:
1.78 + .long 0x00000000
1.79 +
1.80 +
1.81 +__interrupt_handler:
1.82 + .skip 0x100
1.83 +general_exception:
1.84 + mov.l handler_stack_ptr_k, r15
1.85 + mov.l @r15, r15
1.86 + mov.l r0, @-r15
1.87 + mov.l r1, @-r15
1.88 + mov.l r2, @-r15
1.89 +
1.90 + mov.l expevt_k, r0
1.91 + mov.l @r0, r1
1.92 + mov.l expected_expevt_k, r2
1.93 + mov.l @r2, r2
1.94 + cmp/eq r1, r2
1.95 + bf general_not_expected
1.96 + bra ex_expected
1.97 + nop
1.98 +general_not_expected:
1.99 + bra ex_dontcare
1.100 + nop
1.101 + nop
1.102 +expevt_k:
1.103 + .long 0xFF000024
1.104 +expected_expevt_k:
1.105 + .long expected_expevt
1.106 +handler_stack_ptr_k:
1.107 + .long handler_stack_ptr
1.108 + .skip 0x2D4 ! Pad up to 0x400
1.109 +
1.110 +tlb_exception:
1.111 + mov.l handler_stack_ptr, r15
1.112 + mov.l r0, @-r15
1.113 + mov.l r1, @-r15
1.114 + mov.l r2, @-r15
1.115 +
1.116 + mov.l expevt1_k, r0
1.117 + mov.l @r0, r1
1.118 + mov.l expected_expevt1_k, r2
1.119 + mov.l @r2, r2
1.120 + cmp/eq r1, r2
1.121 + bf tlb_not_expected
1.122 + bra ex_expected
1.123 + nop
1.124 +tlb_not_expected:
1.125 + bra ex_dontcare
1.126 + nop
1.127 +expevt1_k:
1.128 + .long 0xFF000024
1.129 +expected_expevt1_k:
1.130 + .long expected_expevt
1.131 +
1.132 + .skip 0x1DC ! Pad up to 0x600
1.133 +
1.134 +irq_raised:
1.135 + mov.l handler_stack_ptr, r15
1.136 + mov.l r0, @-r15
1.137 + mov.l r1, @-r15
1.138 + mov.l r2, @-r15
1.139 +
1.140 + mov.l intevt_k, r0
1.141 + mov.l @r0, r1
1.142 + mov.l expected_intevt_k, r2
1.143 + mov.l @r2, r2
1.144 + cmp/eq r1, r2
1.145 + bf ex_dontcare
1.146 +
1.147 +ex_expected:
1.148 + mov.l interrupt_count_k, r0
1.149 + mov.l @r0, r2
1.150 + add #1, r2
1.151 + mov.l r2, @r0
1.152 + stc spc, r2
1.153 + mov.l interrupt_pc_k, r0
1.154 + mov.l r2, @r0
1.155 +
1.156 +! For most instructions, spc = raising instruction, so add 2 to get the next
1.157 +! instruction. Exceptions are the slot illegals (need pc+4), and trapa/
1.158 +! user-break-after-instruction where the pc is already correct
1.159 + mov.l slot_illegal_k, r0
1.160 + cmp/eq r0, r1
1.161 + bt ex_slot_spc
1.162 + mov.l slot_fpu_disable_k, r0
1.163 + cmp/eq r0, r1
1.164 + bt ex_slot_spc
1.165 + mov.l trapa_exc_k, r0
1.166 + cmp/eq r0, r1
1.167 + bt ex_nochain
1.168 + mov.l break_after_k, r0
1.169 + cmp/eq r0, r1
1.170 + bt ex_nochain
1.171 +! For everything else, spc += 2
1.172 + add #2, r2
1.173 + ldc r2, spc
1.174 + bra ex_nochain
1.175 + nop
1.176 +ex_slot_spc:
1.177 + add #4, r2
1.178 + ldc r2, spc
1.179 + bra ex_nochain
1.180 + nop
1.181 +
1.182 +ex_dontcare: ! Not the event we were waiting for.
1.183 + mov.l old_vbr_k, r2
1.184 + mov.l @r2, r2
1.185 + xor r0, r0
1.186 + cmp/eq r0, r2
1.187 + bt ex_nochain
1.188 +
1.189 + stc ssr, r0
1.190 + mov.l r0, @-r15
1.191 + stc spc, r0
1.192 + mov.l r0, @-r15
1.193 + stc sgr, r0
1.194 + mov.l r0, @-r15
1.195 + mov.l ex_chainreturn, r0
1.196 + ldc r0, spc
1.197 + mova handler_stack_ptr, r0
1.198 + mov.l r15, @r0
1.199 + braf r2 ! Chain on
1.200 + nop
1.201 +
1.202 +ex_chainreturn:
1.203 + mov.l handler_stack_ptr, r15
1.204 + mov.l @r15+, r0
1.205 + ldc r0, sgr
1.206 + mov.l @r15+, r0
1.207 + ldc r0, spc
1.208 + mov.l @r15+, r0
1.209 + ldc r0, ssr
1.210 +
1.211 +ex_nochain: ! No previous vbr to chain to
1.212 + mova handler_stack_ptr, r0
1.213 + mov r15, r1
1.214 + add #12, r1
1.215 + mov.l r1, @r0
1.216 + mov.l @r15+, r2
1.217 + mov.l @r15+, r1
1.218 + mov.l @r15+, r0
1.219 + rte
1.220 + stc sgr, r15
1.221 +
1.222 +.align 4
1.223 +expected_intevt_k:
1.224 + .long expected_intevt
1.225 +interrupt_count_k:
1.226 + .long _interrupt_count
1.227 +interrupt_pc_k:
1.228 + .long _interrupt_pc
1.229 +old_vbr_k:
1.230 + .long old_vbr
1.231 +trapa_k:
1.232 + .long 0xFF000020
1.233 +intevt_k:
1.234 + .long 0xFF000028
1.235 +
1.236 +slot_illegal_k:
1.237 + .long 0x000001A0
1.238 +slot_fpu_disable_k:
1.239 + .long 0x00000820
1.240 +trapa_exc_k:
1.241 + .long 0x00000160
1.242 +break_after_k:
1.243 + .long 0x000001E0
1.244 +
1.245 +handler_stack_ptr:
1.246 + .long handler_stack_end
1.247 +
1.248 +handler_stack:
1.249 + .skip 0x200
1.250 +handler_stack_end:
.