| 1 | /* |
| 2 | * ========== Copyright Header Begin ========================================== |
| 3 | * |
| 4 | * OpenSPARC T2 Processor File: isa3_intlevel_121503.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 | #define MAIN_PAGE_HV_ALSO |
| 39 | ! Enable main section to run in PRIV mode |
| 40 | #define MAIN_PAGE_NUCLEUS_ALSO |
| 41 | |
| 42 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 43 | !Override trap handler definitions |
| 44 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 45 | |
| 46 | ! Trap should set %l6=TT which is verified in main program |
| 47 | ! and set %pil=15 or clear %softint |
| 48 | ! to keep trap from firing again on return from trap |
| 49 | |
| 50 | #define MY_GENERIC_TRAP \ |
| 51 | mov 0xf, %l3; \ |
| 52 | wrpr %l3, %l7, %pil; \ |
| 53 | rdpr %tt, %l6; \ |
| 54 | inc %i7; \ |
| 55 | retry; \ |
| 56 | nop; |
| 57 | |
| 58 | #define H_T0_Interrupt_Level_1_0x41 |
| 59 | #define My_T0_Interrupt_Level_1_0x41 MY_GENERIC_TRAP |
| 60 | |
| 61 | #define H_T0_Interrupt_Level_2_0x42 |
| 62 | #define My_T0_Interrupt_Level_2_0x42 MY_GENERIC_TRAP |
| 63 | |
| 64 | #define H_T0_Interrupt_Level_3_0x43 |
| 65 | #define My_T0_Interrupt_Level_3_0x43 MY_GENERIC_TRAP |
| 66 | |
| 67 | #define H_T0_Interrupt_Level_4_0x44 |
| 68 | #define My_T0_Interrupt_Level_4_0x44 MY_GENERIC_TRAP |
| 69 | |
| 70 | #define H_T0_Interrupt_Level_5_0x45 |
| 71 | #define My_T0_Interrupt_Level_5_0x45 MY_GENERIC_TRAP |
| 72 | |
| 73 | #define H_T0_Interrupt_Level_6_0x46 |
| 74 | #define My_T0_Interrupt_Level_6_0x46 MY_GENERIC_TRAP |
| 75 | |
| 76 | #define H_T0_Interrupt_Level_7_0x47 |
| 77 | #define My_T0_Interrupt_Level_7_0x47 MY_GENERIC_TRAP |
| 78 | |
| 79 | #define H_T0_Interrupt_Level_8_0x48 |
| 80 | #define My_T0_Interrupt_Level_8_0x48 MY_GENERIC_TRAP |
| 81 | |
| 82 | #define H_T0_Interrupt_Level_9_0x49 |
| 83 | #define My_T0_Interrupt_Level_9_0x49 MY_GENERIC_TRAP |
| 84 | |
| 85 | #define H_T0_Interrupt_Level_10_0x4a |
| 86 | #define My_T0_Interrupt_Level_10_0x4a MY_GENERIC_TRAP |
| 87 | |
| 88 | #define H_T0_Interrupt_Level_11_0x4b |
| 89 | #define My_T0_Interrupt_Level_11_0x4b MY_GENERIC_TRAP |
| 90 | |
| 91 | #define H_T0_Interrupt_Level_12_0x4c |
| 92 | #define My_T0_Interrupt_Level_12_0x4c MY_GENERIC_TRAP |
| 93 | |
| 94 | #define H_T0_Interrupt_Level_13_0x4d |
| 95 | #define My_T0_Interrupt_Level_13_0x4d MY_GENERIC_TRAP |
| 96 | |
| 97 | #define H_T0_Interrupt_Level_14_0x4e |
| 98 | #define My_T0_Interrupt_Level_14_0x4e MY_GENERIC_TRAP |
| 99 | |
| 100 | #define H_T0_Interrupt_Level_15_0x4f |
| 101 | #define My_T0_Interrupt_Level_15_0x4f MY_GENERIC_TRAP |
| 102 | |
| 103 | #define CREGS_PSTATE_IE 1 ! Set PSTATE.IE=1 |
| 104 | |
| 105 | #include "hboot.s" |
| 106 | |
| 107 | /************************************************************************ |
| 108 | Test case code start |
| 109 | ************************************************************************/ |
| 110 | |
| 111 | .text |
| 112 | .global main |
| 113 | |
| 114 | main: /* test begin */ |
| 115 | |
| 116 | ta T_CHANGE_PRIV ! Change to PRIV mode |
| 117 | |
| 118 | ! local reg usage for this diag |
| 119 | ! %l0 = 0x0 always |
| 120 | ! %l1 = n = interrupt level |
| 121 | ! %l2 = tmp register |
| 122 | ! %l3 = tmp register |
| 123 | ! %l4 = SOFTINT value |
| 124 | ! %l5 = PIL value |
| 125 | ! %l6 = TT value |
| 126 | ! %l7 = tmp register |
| 127 | ! %i7 = number of traps taken |
| 128 | |
| 129 | init: |
| 130 | ! Clear local regs for scratch registers |
| 131 | nop |
| 132 | mov 0x0, %l0 |
| 133 | mov 0x0, %l1 |
| 134 | mov 0x0, %l2 |
| 135 | mov 0x0, %l3 |
| 136 | mov 0x0, %l4 |
| 137 | mov 0x0, %l5 |
| 138 | mov 0x0, %l6 |
| 139 | mov 0x0, %i7 |
| 140 | nop |
| 141 | |
| 142 | ! Verify interrupt_level_n (where n=1..15) one at a time |
| 143 | |
| 144 | ! Turn off interrupts by setting PIL=15 |
| 145 | mov 0xf, %l3 |
| 146 | wrpr %l3, %l7, %pil |
| 147 | |
| 148 | ! Set loop cnt = n = interrupt_level |
| 149 | mov 0xf, %l1 |
| 150 | |
| 151 | intr_loop: |
| 152 | ! Set %l6=0x0 |
| 153 | mov 0x0, %l6 |
| 154 | ! Write n to SOFTINT |
| 155 | mov 0x1, %l2 |
| 156 | sll %l2, %l1, %l4 |
| 157 | wr %l4, %l7, %set_softint |
| 158 | ! Write n-1 to PIL |
| 159 | sub %l1, 0x1, %l5 |
| 160 | wrpr %l5, %l7, %pil |
| 161 | nop |
| 162 | |
| 163 | chk_trap: |
| 164 | ! Turn off SOFTINT bit |
| 165 | wr %l4, %l7, %clear_softint |
| 166 | ! Verify that trap was taken, %l6=TT=0x40+n |
| 167 | sub %l6, 0x40, %l2 |
| 168 | cmp %l2, %l1 |
| 169 | bne failed |
| 170 | nop |
| 171 | |
| 172 | go_loop: |
| 173 | !Decrement loop cnt, repeat 15 times |
| 174 | dec %l1 |
| 175 | cmp %l1, 0x0 |
| 176 | bne intr_loop |
| 177 | nop |
| 178 | |
| 179 | ! Verify we took 15 traps |
| 180 | cmp %i7, 0xf |
| 181 | bne failed |
| 182 | nop |
| 183 | |
| 184 | misc: |
| 185 | ! Set PIL=15 |
| 186 | mov 0xf, %l3 |
| 187 | wrpr %l3, %l7, %pil |
| 188 | |
| 189 | ! Rd/Wr SOFTINT Directly |
| 190 | ! Set SOFTINT |
| 191 | setx 0x1ffff, %l7, %l2 |
| 192 | wr %l2, %l7, %softint |
| 193 | clr %l3 |
| 194 | rd %softint, %l3 |
| 195 | cmp %l3, %l2 |
| 196 | bne failed |
| 197 | |
| 198 | ! Clear SOFTINT |
| 199 | clr %l2 |
| 200 | wr %l2, %l7, %softint |
| 201 | clr %l3 |
| 202 | rd %softint, %l3 |
| 203 | cmp %l3, %l2 |
| 204 | bne failed |
| 205 | nop |
| 206 | |
| 207 | passed: |
| 208 | EXIT_GOOD /* test finish */ |
| 209 | |
| 210 | failed: |
| 211 | EXIT_BAD |
| 212 | |
| 213 | |
| 214 | /************************************************************************ |
| 215 | Test case data start |
| 216 | ************************************************************************/ |
| 217 | .data |
| 218 | user_data_start: |
| 219 | .word 0xB52E8698 |
| 220 | .end |
| 221 | |