| 1 | /* |
| 2 | * ========== Copyright Header Begin ========================================== |
| 3 | * |
| 4 | * OpenSPARC T2 Processor File: daccess_except_handler.s |
| 5 | * Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved |
| 6 | * 4150 Network Circle, Santa Clara, California 95054, U.S.A. |
| 7 | * |
| 8 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation; version 2 of the License. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 22 | * |
| 23 | * For the avoidance of doubt, and except that if any non-GPL license |
| 24 | * choice is available it will apply instead, Sun elects to use only |
| 25 | * the General Public License version 2 (GPLv2) at this time for any |
| 26 | * software where a choice of GPL license versions is made |
| 27 | * available with the language indicating that GPLv2 or any later version |
| 28 | * may be used, or where a choice of which version of the GPL is applied is |
| 29 | * otherwise unspecified. |
| 30 | * |
| 31 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 32 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 33 | * have any questions. |
| 34 | * |
| 35 | * |
| 36 | * ========== Copyright Header End ============================================ |
| 37 | */ |
| 38 | daccess_except_handler: |
| 39 | #ifdef CHECK_SFSR_SFAR |
| 40 | mov 0x18, %g7 |
| 41 | ldxa [%g7] 0x58, %g2 ! get sfsr |
| 42 | mov 0x20, %g7 |
| 43 | ldxa [%g7] 0x58, %g3 ! get sfar |
| 44 | #endif |
| 45 | |
| 46 | dacc_ex_ps0: |
| 47 | ldxa [%g0] 0x59, %g1 ! dmmu ps0 ptr |
| 48 | ldda [%g1] 0x24, %g4 ! load tte from ps0 tsb |
| 49 | cmp %g4, -1 ! if all 1's, follow link |
| 50 | be,a %xcc, dacc_ex_ptr_chase |
| 51 | mov 0, %g7 ! remember ptr chase from ps0 |
| 52 | srlx %g5, 63, %g3 ! if not valid, check ps1 |
| 53 | brz %g3, dacc_ex_ps1 |
| 54 | |
| 55 | #ifndef SUN4V |
| 56 | sllx %g5, 15, %g3 ! extract size[2] |
| 57 | srlx %g3, 61, %g3 |
| 58 | sllx %g5, 1, %g1 ! extract size[1:0] |
| 59 | srlx %g1, 62, %g1 |
| 60 | or %g3, %g1, %g1 ! %g1 = size[2:0] |
| 61 | #else |
| 62 | sllx %g5, 61, %g1 |
| 63 | srlx %g1, 61, %g1 ! %g1 = size[2:0] |
| 64 | #endif |
| 65 | mulx %g1, 3, %g1 |
| 66 | sub %g0, 1, %g3 |
| 67 | sllx %g3, 13, %g3 |
| 68 | sllx %g3, %g1, %g3 |
| 69 | sethi %hi(0x00001fff), %g1 |
| 70 | or %g1, 0xfff, %g1 |
| 71 | or %g3, %g1, %g3 ! %g3 = va/ctxt mask based on size[2:0] |
| 72 | |
| 73 | and %g2, %g3, %g3 ! apply mask |
| 74 | cmp %g3, %g4 ! check if va/ctxt match |
| 75 | be %xcc, dacc_ex_trap_done |
| 76 | nop |
| 77 | |
| 78 | dacc_ex_ps1: |
| 79 | ldxa [%g0] 0x5a, %g1 ! dmmu ps1 ptr |
| 80 | ldda [%g1] 0x24, %g4 ! load tte from ps1 tsb |
| 81 | cmp %g4, -1 ! if all 1's, follow link |
| 82 | be,a %xcc, dacc_ex_ptr_chase |
| 83 | mov 1, %g7 ! remember ptr chase from ps1 |
| 84 | srlx %g5, 63, %g3 ! if not valid, bad_trap |
| 85 | !brz %g3, bad_trap |
| 86 | cmp %g3, 0x0 |
| 87 | tz T_BAD_TRAP |
| 88 | |
| 89 | |
| 90 | #ifndef SUN4V |
| 91 | sllx %g5, 15, %g3 ! extract size[2] |
| 92 | srlx %g3, 61, %g3 |
| 93 | sllx %g5, 1, %g1 ! extract size[1:0] |
| 94 | srlx %g1, 62, %g1 |
| 95 | or %g3, %g1, %g1 ! %g1 = size[2:0] |
| 96 | #else |
| 97 | sllx %g5, 61, %g1 |
| 98 | srlx %g1, 61, %g1 ! %g1 = size[2:0] |
| 99 | #endif |
| 100 | mulx %g1, 3, %g1 |
| 101 | sub %g0, 1, %g3 |
| 102 | sllx %g3, 13, %g3 |
| 103 | sllx %g3, %g1, %g3 |
| 104 | sethi %hi(0x00001fff), %g1 |
| 105 | or %g1, 0xfff, %g1 |
| 106 | or %g3, %g1, %g3 ! %g3 = va/ctxt mask based on size[2:0] |
| 107 | |
| 108 | and %g2, %g3, %g3 ! apply mask |
| 109 | cmp %g3, %g4 ! check if va/ctxt match |
| 110 | be %xcc, dacc_ex_trap_done |
| 111 | nop |
| 112 | |
| 113 | ta T_BAD_TRAP |
| 114 | nop |
| 115 | |
| 116 | dacc_ex_ptr_chase: |
| 117 | or %g5, %g0, %g6 ! %g6 is link-reg |
| 118 | dacc_ex_ptr_chase_loop: |
| 119 | ldda [%g6] 0x24, %g4 ! load tte from tsb |
| 120 | |
| 121 | #ifndef SUN4V |
| 122 | sllx %g5, 15, %g3 ! extract size[2] |
| 123 | srlx %g3, 61, %g3 |
| 124 | sllx %g5, 1, %g1 ! extract size[1:0] |
| 125 | srlx %g1, 62, %g1 |
| 126 | or %g3, %g1, %g1 ! %g1 = size[2:0] |
| 127 | #else |
| 128 | sllx %g5, 61, %g1 |
| 129 | srlx %g1, 61, %g1 ! %g1 = size[2:0] |
| 130 | #endif |
| 131 | mulx %g1, 3, %g1 |
| 132 | sub %g0, 1, %g3 |
| 133 | sllx %g3, 13, %g3 |
| 134 | sllx %g3, %g1, %g3 |
| 135 | sethi %hi(0x00001fff), %g1 |
| 136 | or %g1, 0xfff, %g1 |
| 137 | or %g3, %g1, %g3 ! %g3 = va/ctxt mask based on size[2:0] |
| 138 | |
| 139 | and %g2, %g3, %g3 ! apply mask |
| 140 | cmp %g3, %g4 ! check if va/ctxt match |
| 141 | be %xcc, dacc_ex_trap_done |
| 142 | |
| 143 | ldx [%g6+16], %g6 |
| 144 | cmp %g6, -1 |
| 145 | bne %xcc, dacc_ex_ptr_chase_loop ! keep chasing pointer |
| 146 | nop |
| 147 | brz %g7, dacc_ex_ps1 ! finished ps0 pointer chasing, go to ps1 |
| 148 | nop |
| 149 | ta T_BAD_TRAP ! finished ps1 pointer chasing, go to bad_trap |
| 150 | nop |
| 151 | |
| 152 | dacc_ex_trap_done: |
| 153 | ! add partition base to data-in |
| 154 | setx partition_base_list, %g1, %g2 ! for partition base |
| 155 | mov 0x80, %g1 ! offset (VA) for patrition id |
| 156 | ldxa [%g1] 0x58, %g3 ! partition id |
| 157 | sllx %g3, 3, %g3 ! offset - partition list |
| 158 | ldx [%g2 + %g3], %g1 |
| 159 | add %g5, %g1, %g5 |
| 160 | mov 0x4, %g1 ! clear P-bit |
| 161 | not %g1 |
| 162 | and %g1, %g5, %g5 |
| 163 | mov 0x30, %g7 |
| 164 | mov %g0, %g6 |
| 165 | stxa %g4, [ %g7 ] 0x58 ! {tag-access, data-in} |
| 166 | stxa %g5, [ %g6 ] 0x5c |
| 167 | retry |
| 168 | |