| 1 | #
|
|---|
| 2 | # Copyright (C) 2006 Martin Decky
|
|---|
| 3 | # All rights reserved.
|
|---|
| 4 | #
|
|---|
| 5 | # Redistribution and use in source and binary forms, with or without
|
|---|
| 6 | # modification, are permitted provided that the following conditions
|
|---|
| 7 | # are met:
|
|---|
| 8 | #
|
|---|
| 9 | # - Redistributions of source code must retain the above copyright
|
|---|
| 10 | # notice, this list of conditions and the following disclaimer.
|
|---|
| 11 | # - Redistributions in binary form must reproduce the above copyright
|
|---|
| 12 | # notice, this list of conditions and the following disclaimer in the
|
|---|
| 13 | # documentation and/or other materials provided with the distribution.
|
|---|
| 14 | # - The name of the author may not be used to endorse or promote products
|
|---|
| 15 | # derived from this software without specific prior written permission.
|
|---|
| 16 | #
|
|---|
| 17 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|---|
| 18 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|---|
| 19 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|---|
| 20 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|---|
| 21 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|---|
| 22 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|---|
| 23 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|---|
| 24 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|---|
| 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|---|
| 26 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|---|
| 27 | #
|
|---|
| 28 |
|
|---|
| 29 | #include <arch/asm/regname.h>
|
|---|
| 30 | #include <arch/mm/page.h>
|
|---|
| 31 |
|
|---|
| 32 | .section K_UNMAPPED_TEXT_START, "ax"
|
|---|
| 33 |
|
|---|
| 34 | .macro CONTEXT_STORE
|
|---|
| 35 | mtspr sprg1, sp
|
|---|
| 36 |
|
|---|
| 37 | subis sp, sp, 0x8000
|
|---|
| 38 |
|
|---|
| 39 | subi sp, sp, 144
|
|---|
| 40 | stw r0, 0(sp)
|
|---|
| 41 | stw r2, 4(sp)
|
|---|
| 42 | stw r3, 8(sp)
|
|---|
| 43 | stw r4, 12(sp)
|
|---|
| 44 | stw r5, 16(sp)
|
|---|
| 45 | stw r6, 20(sp)
|
|---|
| 46 | stw r7, 24(sp)
|
|---|
| 47 | stw r8, 28(sp)
|
|---|
| 48 | stw r9, 32(sp)
|
|---|
| 49 | stw r10, 36(sp)
|
|---|
| 50 | stw r11, 40(sp)
|
|---|
| 51 | stw r12, 44(sp)
|
|---|
| 52 | stw r13, 48(sp)
|
|---|
| 53 | stw r14, 52(sp)
|
|---|
| 54 | stw r15, 56(sp)
|
|---|
| 55 | stw r16, 60(sp)
|
|---|
| 56 | stw r17, 64(sp)
|
|---|
| 57 | stw r18, 68(sp)
|
|---|
| 58 | stw r19, 72(sp)
|
|---|
| 59 | stw r20, 76(sp)
|
|---|
| 60 | stw r21, 80(sp)
|
|---|
| 61 | stw r22, 84(sp)
|
|---|
| 62 | stw r23, 88(sp)
|
|---|
| 63 | stw r24, 92(sp)
|
|---|
| 64 | stw r25, 96(sp)
|
|---|
| 65 | stw r26, 100(sp)
|
|---|
| 66 | stw r27, 104(sp)
|
|---|
| 67 | stw r28, 108(sp)
|
|---|
| 68 | stw r29, 112(sp)
|
|---|
| 69 | stw r30, 116(sp)
|
|---|
| 70 | stw r31, 120(sp)
|
|---|
| 71 |
|
|---|
| 72 | mfspr r3, srr0
|
|---|
| 73 | stw r3, 124(sp)
|
|---|
| 74 |
|
|---|
| 75 | mfspr r3, srr1
|
|---|
| 76 | stw r3, 128(sp)
|
|---|
| 77 |
|
|---|
| 78 | mflr r3
|
|---|
| 79 | stw r3, 132(sp)
|
|---|
| 80 |
|
|---|
| 81 | mfcr r3
|
|---|
| 82 | stw r3, 136(sp)
|
|---|
| 83 |
|
|---|
| 84 | mfctr r3
|
|---|
| 85 | stw r3, 140(sp)
|
|---|
| 86 |
|
|---|
| 87 | mfxer r3
|
|---|
| 88 | stw r3, 144(sp)
|
|---|
| 89 | .endm
|
|---|
| 90 |
|
|---|
| 91 | .org 0x100
|
|---|
| 92 | .global exc_system_reset
|
|---|
| 93 | exc_system_reset:
|
|---|
| 94 | b exc_system_reset
|
|---|
| 95 |
|
|---|
| 96 | .org 0x200
|
|---|
| 97 | .global exc_machine_check
|
|---|
| 98 | exc_machine_check:
|
|---|
| 99 | b exc_machine_check
|
|---|
| 100 |
|
|---|
| 101 | .org 0x300
|
|---|
| 102 | .global exc_data_storage
|
|---|
| 103 | exc_data_storage:
|
|---|
| 104 | CONTEXT_STORE
|
|---|
| 105 |
|
|---|
| 106 | lis r3, pht_refill@ha
|
|---|
| 107 | addi r3, r3, pht_refill@l
|
|---|
| 108 | mtspr srr0, r3
|
|---|
| 109 |
|
|---|
| 110 | mfmsr r3
|
|---|
| 111 | ori r3, r3, (msr_ir | msr_dr)@l
|
|---|
| 112 | mtspr srr1, r3
|
|---|
| 113 |
|
|---|
| 114 | lis r3, iret@ha
|
|---|
| 115 | addi r3, r3, iret@l
|
|---|
| 116 | mtlr r3
|
|---|
| 117 |
|
|---|
| 118 | addis sp, sp, 0x8000
|
|---|
| 119 | rfi
|
|---|
| 120 |
|
|---|
| 121 | .org 0x400
|
|---|
| 122 | .global exc_instruction_storage
|
|---|
| 123 | exc_instruction_storage:
|
|---|
| 124 | b exc_instruction_storage
|
|---|
| 125 |
|
|---|
| 126 | .org 0x480
|
|---|
| 127 | .global exc_instruction_segment
|
|---|
| 128 | exc_instruction_segment:
|
|---|
| 129 | b exc_instruction_segment
|
|---|
| 130 |
|
|---|
| 131 | .org 0x500
|
|---|
| 132 | .global exc_external
|
|---|
| 133 | exc_external:
|
|---|
| 134 | b exc_external
|
|---|
| 135 |
|
|---|
| 136 | .org 0x600
|
|---|
| 137 | .global exc_alignment
|
|---|
| 138 | exc_alignment:
|
|---|
| 139 | b exc_alignment
|
|---|
| 140 |
|
|---|
| 141 | .org 0x700
|
|---|
| 142 | .global exc_program
|
|---|
| 143 | exc_program:
|
|---|
| 144 | b exc_program
|
|---|
| 145 |
|
|---|
| 146 | .org 0x800
|
|---|
| 147 | .global exc_fp_unavailable
|
|---|
| 148 | exc_fp_unavailable:
|
|---|
| 149 | b exc_fp_unavailable
|
|---|
| 150 |
|
|---|
| 151 | .org 0x900
|
|---|
| 152 | .global exc_decrementer
|
|---|
| 153 | exc_decrementer:
|
|---|
| 154 | CONTEXT_STORE
|
|---|
| 155 |
|
|---|
| 156 | lis r3, exc_dispatch@ha
|
|---|
| 157 | addi r3, r3, exc_dispatch@l
|
|---|
| 158 | mtspr srr0, r3
|
|---|
| 159 |
|
|---|
| 160 | mfmsr r3
|
|---|
| 161 | ori r3, r3, (msr_ir | msr_dr)@l
|
|---|
| 162 | mtspr srr1, r3
|
|---|
| 163 |
|
|---|
| 164 | lis r3, iret@ha
|
|---|
| 165 | addi r3, r3, iret@l
|
|---|
| 166 | mtlr r3
|
|---|
| 167 |
|
|---|
| 168 | addis sp, sp, 0x8000
|
|---|
| 169 | li r3, 10
|
|---|
| 170 | rfi
|
|---|
| 171 |
|
|---|
| 172 | .org 0xa00
|
|---|
| 173 | .global exc_reserved0
|
|---|
| 174 | exc_reserved0:
|
|---|
| 175 | b exc_reserved0
|
|---|
| 176 |
|
|---|
| 177 | .org 0xb00
|
|---|
| 178 | .global exc_reserved1
|
|---|
| 179 | exc_reserved1:
|
|---|
| 180 | b exc_reserved1
|
|---|
| 181 |
|
|---|
| 182 | .org 0xc00
|
|---|
| 183 | .global exc_syscall
|
|---|
| 184 | exc_syscall:
|
|---|
| 185 | b exc_syscall
|
|---|
| 186 |
|
|---|
| 187 | .org 0xd00
|
|---|
| 188 | .global exc_trace
|
|---|
| 189 | exc_trace:
|
|---|
| 190 | b exc_trace
|
|---|