Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / diag / assembly / uarch / tlu / src / tlu_swtraps.pal
:!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
:!
:! TLU SW trap sweep testing
:!
:! This diag attempts to hit all the software traps for user/super/hyper
:! modes
:!
:! For each trap, replace the 1st instruction in trap handler with
:! 'done', then execute the SW trap and afterwards replace the original
:! handler instruction back ...
:!
:! SAT : SPC2 or higher ..
:!
:!
:!
# PAL routines used in Diag
# Set random seed
srand(137329);
@levels = (0..6);
@all_sw_trap_type = qw(100 101 102 103 104 105 106 107 108 109
10a 10b 10c 10d 10e 10f 110 111 112 113 114 115 116
117 118 119 11a 11b 11c 11d 11e 11f 120 121 122 123
124 125 126 127 128 129 12a 12b 12c 12d 12e 12f 130
131 132 133 134 135 136 137 138 139 13a 13b 13c 13d
13e 13f 140 141 142 143 144 145 146 147 148 149 14a
14b 14c 14d 14e 14f 150 151 152 153 154 155 156 157
158 159 15a 15b 15c 15d 15e 15f 160 161 162 163 164
165 166 167 168 169 16a 16b 16c 16d 16e 16f 170 171
172 173 174 175 176 177 178 179 17a 17b 17c 17d 17e
17f 180 181 182 183 184 185 186 187 188 189 18a 18b
18c 18d 18e 18f 190 191 192 193 194 195 196 197 198
199 19a 19b 19c 19d 19e 19f 1a0 1a1 1a2 1a3 1a4 1a5
1a6 1a7 1a8 1a9 1aa 1ab 1ac 1ad 1ae 1af 1b0 1b1 1b2
1b3 1b4 1b5 1b6 1b7 1b8 1b9 1ba 1bb 1bc 1bd 1be 1bf
1c0 1c1 1c2 1c3 1c4 1c5 1c6 1c7 1c8 1c9 1ca 1cb 1cc
1cd 1ce 1cf 1d0 1d1 1d2 1d3 1d4 1d5 1d6 1d7 1d8 1d9
1da 1db 1dc 1dd 1de 1df 1e0 1e1 1e2 1e3 1e4 1e5 1e6
1e7 1e8 1e9 1ea 1eb 1ec 1ed 1ee 1ef 1f0 1f1 1f2 1f3
1f4 1f5 1f6 1f7 1f8 1f9 1fa 1fb 1fc 1fd 1fe 1ff
);
@reserved_traps = qw(100 101 102 103 120 122 180 181 182 1a0 1a1);
# Function to return a random number ..
sub get_rand {return int (rand $_[0])}
# Diag Starts :
:#define MAIN_PAGE_HV_ALSO
:#define MAIN_PAGE_NUCLEUS_ALSO
:#define DONE_OPCODE 0x81f00000
:#define H_HT0_Illegal_instruction_0x10
:#define My_HT0_Illegal_instruction_0x10 \
: done;nop
:
:#define H_HT0_Watchdog_Reset_0x02
:#define My_HT0_Watchdog_Reset_0x02 \
: rdpr %tt, %g1;\
: cmp %g1, 0x120;\
: te T_API_CHANGE_PRIV ;\
: rdhpr %htba, %g2;\
: sllx %g1, 5, %g1;\
: add %g2, %g1, %g2;\
: jmp %g2;\
: nop;\
:
:#define My_RED_Mode_Other_Reset \
: rdpr %tt, %g1;\
: cmp %g1, 0x120;\
: te T_API_CHANGE_PRIV ;\
: rdhpr %htba, %g2;\
: sllx %g1, 5, %g1;\
: add %g2, %g1, %g2;\
: jmp %g2;\
: nop;\
:
:#define My_Watchdog_Reset \
: rdpr %tt, %g1;\
: cmp %g1, 0x120;\
: te T_API_CHANGE_PRIV ;\
: rdhpr %htba, %g2;\
: sllx %g1, 5, %g1;\
: add %g2, %g1, %g2;\
: jmp %g2;\
: nop;\
:
:
:#include "hboot.s"
:
:.text
:.global main
:
:main:
:
: ta T_RD_THID
: brnz %o1, wait_for_ttable_rewrite
: nop
: ! T0 does ttable update
: ta T_CHANGE_HPRIV
: set HV_TRAP_BASE_PA, %r23 ! Save HTrap Base Address
: set TRAP_BASE_VA, %r22 ! Save Trap Base Address
: set (1<<14), %r24
:
: setx testing_traps, %r21, %r20
:
:next_tt:
: set DONE_OPCODE, %r21 ! Done opcode
: ldx [%r20], %r19 ! Get TT offset
: brz %r19, done_ttable_rewrite
: stw %r21, [%r19+%r23] ! Write 'done in Htrap handler
: stwa %r21, [%r19+%r22]ASI_REAL_MEM ! Write 'done in trap(0) handler
: or %r19, %r24, %r19
: stwa %r21, [%r19+%r22]ASI_REAL_MEM ! Write 'done in trap(1) handler
: add %r20, 8, %r20 ! Next address
: b next_tt
: nop
:done_ttable_rewrite:
: ta T_CHANGE_NONHPRIV
: setx done_tt_update, %g1, %g2
: stx %r20, [%g2]
: b begin_sw_tt_test
: nop
:
:wait_for_ttable_rewrite: ! All other threads wait here
: mov 0x50, %g1
: setx rand_word1, %g3, %g2
: ldd [%g2], %f0
: stx %g1, [%g2+16]
: ldd [%g2+16], %f2
: fdivs %f0, %f2, %f4
: setx done_tt_update, %g1, %g2
: ldx [%g2], %g1
: brz %g1, wait_for_ttable_rewrite
: nop
:
:begin_sw_tt_test:
:
foreach $tl (@levels) {
:
if ($tl <3) {
: ta T_CHANGE_HPRIV
: wrpr %g0, $tl, %tl
: ta T_CHANGE_NONPRIV
: ta T_CHANGE_NONHPRIV
:
:
:! User SW trap testing - level $tl:
foreach $ttype (@all_sw_trap_type) {
next if (grep(/^$ttype$/, @reserved_traps));
:! SW trap # $ttype
:user_${tl}_tt_$ttype:
: ta (0x$ttype-0x100)
:
}
:
:! Priv SW trap testing - level $tl:
: ta T_CHANGE_PRIV
foreach $ttype (@all_sw_trap_type) {
next if (grep(/^$ttype$/, @reserved_traps));
:! SW trap # $ttype
:priv_${tl}_tt_$ttype:
: ta (0x$ttype-0x100)
:
}
:
:! Hyper SW trap testing - level $tl:
:
: ta T_CHANGE_HPRIV
foreach $ttype (@all_sw_trap_type) {
next if (grep(/^$ttype$/, @reserved_traps));
:! SW trap # $ttype
:hpriv_${tl}_tt_$ttype:
: ta (0x$ttype-0x100)
:
}
} else {
:
:
:! Hyper SW trap testing - level $tl:
: wrpr %g0, $tl, %tl
:
foreach $ttype (@all_sw_trap_type) {
next if (grep(/^$ttype$/, @reserved_traps));
:! SW trap # $ttype
:hpriv_${tl}_tt_$ttype:
: ta (0x$ttype-0x100)
:
}
}
:
}
:
:
:finished:
: ta T_CHANGE_NONPRIV
: EXIT_GOOD
: nop
:
:
:.data
:rand_word1:
: .xword 0xcfabdce123469ef0
: .xword 0x2355ce123470e901
:rand_word2:
: .xword 0x0
: .xword 0x0
: .xword 0x0
:done_tt_update:
: .xword 0x0
:
:testing_traps:
foreach $ttype (@all_sw_trap_type) {
next if (grep(/^$ttype$/, @reserved_traps));
: .xword (0x$ttype << 5)
}
: .xword 0x0