Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / diag / assembly / include / iaccess_except_handler.s
CommitLineData
86530b38
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: iaccess_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*/
38iaccess_except_handler:
39#ifdef CHECK_SFSR_SFAR
40 mov 0x18, %g7
41 ldxa [%g7] 0x50, %g2 ! get sfsr
42#endif
43
44iacc_ex_ps0:
45 ldxa [%g0] 0x51, %g1 ! immu ps0 ptr
46 ldda [%g1] 0x24, %g4 ! load tte from ps0 tsb
47 cmp %g4, -1 ! if all 1's, follow link
48 be,a %xcc, iacc_ex_ptr_chase
49 mov 0, %g7 ! remember ptr chase from ps0
50 srlx %g5, 63, %g3 ! if not valid, check ps1
51 brz %g3, iacc_ex_ps1
52
53#ifndef SUN4V
54 sllx %g5, 15, %g3 ! extract size[2]
55 srlx %g3, 61, %g3
56 sllx %g5, 1, %g1 ! extract size[1:0]
57 srlx %g1, 62, %g1
58 or %g3, %g1, %g1 ! %g1 = size[2:0]
59#else
60 sllx %g5, 61, %g1
61 srlx %g1, 61, %g1 ! %g1 = size[2:0]
62#endif
63 mulx %g1, 3, %g1
64 sub %g0, 1, %g3
65 sllx %g3, 13, %g3
66 sllx %g3, %g1, %g3
67 sethi %hi(0x00001fff), %g1
68 or %g1, 0xfff, %g1
69 or %g3, %g1, %g3 ! %g3 = va/ctxt mask based on size[2:0]
70
71 and %g2, %g3, %g3 ! apply mask
72 cmp %g3, %g4 ! check if va/ctxt match
73 be %xcc, iacc_ex_trap_done
74 nop
75
76iacc_ex_ps1:
77 ldxa [%g0] 0x52, %g1 ! immu ps1 ptr
78 ldda [%g1] 0x24, %g4 ! load tte from ps1 tsb
79 cmp %g4, -1 ! if all 1's, follow link
80 be,a %xcc, iacc_ex_ptr_chase
81 mov 1, %g7 ! remember ptr chase from ps1
82 srlx %g5, 63, %g3 ! if not valid, bad_trap
83 !brz %g3, bad_trap
84 cmp %g3, 0
85 tz T_BAD_TRAP
86
87#ifndef SUN4V
88 sllx %g5, 15, %g3 ! extract size[2]
89 srlx %g3, 61, %g3
90 sllx %g5, 1, %g1 ! extract size[1:0]
91 srlx %g1, 62, %g1
92 or %g3, %g1, %g1 ! %g1 = size[2:0]
93#else
94 sllx %g5, 61, %g1
95 srlx %g1, 61, %g1 ! %g1 = size[2:0]
96#endif
97 mulx %g1, 3, %g1
98 sub %g0, 1, %g3
99 sllx %g3, 13, %g3
100 sllx %g3, %g1, %g3
101 sethi %hi(0x00001fff), %g1
102 or %g1, 0xfff, %g1
103 or %g3, %g1, %g3 ! %g3 = va/ctxt mask based on size[2:0]
104
105 and %g2, %g3, %g3 ! apply mask
106 cmp %g3, %g4 ! check if va/ctxt match
107 be %xcc, iacc_ex_trap_done
108 nop
109
110 ta T_BAD_TRAP
111 nop
112
113iacc_ex_ptr_chase:
114 or %g5, %g0, %g6 ! %g6 is link-reg
115iacc_ex_ptr_chase_loop:
116 ldda [%g6] 0x24, %g4 ! load tte from tsb
117
118#ifndef SUN4V
119 sllx %g5, 15, %g3 ! extract size[2]
120 srlx %g3, 61, %g3
121 sllx %g5, 1, %g1 ! extract size[1:0]
122 srlx %g1, 62, %g1
123 or %g3, %g1, %g1 ! %g1 = size[2:0]
124#else
125 sllx %g5, 61, %g1
126 srlx %g1, 61, %g1 ! %g1 = size[2:0]
127#endif
128 mulx %g1, 3, %g1
129 sub %g0, 1, %g3
130 sllx %g3, 13, %g3
131 sllx %g3, %g1, %g3
132 sethi %hi(0x00001fff), %g1
133 or %g1, 0xfff, %g1
134 or %g3, %g1, %g3 ! %g3 = va/ctxt mask based on size[2:0]
135
136 and %g2, %g3, %g3 ! apply mask
137 cmp %g3, %g4 ! check if va/ctxt match
138 be %xcc, iacc_ex_trap_done
139
140 ldx [%g6+16], %g6
141 cmp %g6, -1
142 bne %xcc, iacc_ex_ptr_chase_loop ! keep chasing pointer
143 nop
144 brz %g7, iacc_ex_ps1 ! finished ps0 pointer chasing, go to ps1
145 nop
146 ta T_BAD_TRAP ! finished ps1 pointer chasing, go to bad_trap
147 nop
148
149iacc_ex_trap_done:
150 ! add partition base to data-in
151 setx partition_base_list, %g1, %g2 ! for partition base
152 mov 0x80, %g1 ! offset (VA) for patrition id
153 ldxa [%g1] 0x58, %g3 ! partition id
154 sllx %g3, 3, %g3 ! offset - partition list
155 ldx [%g2 + %g3], %g1
156 add %g5, %g1, %g5
157 mov 0x4, %g1 ! clear P-bit
158 not %g1
159 and %g1, %g5, %g5
160 mov 0x30, %g7
161 mov %g0, %g6
162 stxa %g4, [ %g7 ] 0x50 ! {tag-access, data-in}
163 stxa %g5, [ %g6 ] 0x54
164 retry
165
166
167
168