Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / diag / assembly / uarch / tlu / diag / tlu_halt_modint_cancel.s
CommitLineData
86530b38
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: tlu_halt_modint_cancel.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
40#include "hboot.s"
41
42/************************************************************************
43 Test case code start
44 ************************************************************************/
45
46.text
47.global main
48
49main: /* test begin */
50
51
52 ta T_CHANGE_HPRIV
53
54 ! If MT, then park all threads based on park_mask
55 ! Unpark the next thread when finished with this one..
56 ! %l1 contains is_mt, %l2 contains address of is_mt
57 ! %l3 contains park_mask, %l4 contains address of park_mask
58 ! % l5 is mutex address
59
60setup_for_mt: ! {{{
61 setx is_mt, %g1, %l2
62 add %l2, 8, %l4
63 add %l4, 8, %l5
64 ldx [%l5], %g1
65 ldstub [%l5], %g1
66get_mutex:
67 ldx [%l5], %g2
68 brnz,a %g1, get_mutex
69 ldstub [%l5], %g1
70
71check_is_mt_set:
72 ldx [%l2], %l1
73 brnz %l1, continue
74 mov 0x58, %g3
75is_mt_not_set:
76 ldxa [%g3]0x41, %l1
77 popc %l1, %l1
78 dec %l1
79 brz %l1, continue
80 nop
81is_mt_and_first:
82 mov 0x50, %g3
83 stxa %g0, [%g3] 0x41 ! Park all threads
84 mov 50, %g1
85wait:
86 brnz,a %g1, wait
87 dec %g1
88
89 stx %l1, [%l2] ! Set the MT flag
90 mov 1, %g1
91 stx %g0, [%l5] ! release mutex
92 stxa %g1, [%g3] 0x41 ! Start with T0
93
94continue:
95 stx %g0, [%l5] ! release mutex
96
97! }}}
98
99test1:
100 wrpr %g0, 0x0, %pstate ! disable IE
101
102
103 !# Write bit 9 of MACTL (causes interrupt upon completion)
104 !# 21:0 == 00 0010 0000 0000 0011 1111
105 !# 20:18 TID == 0..7
106 !# 17 cause interrupt
107 !# 12:08 modular addition (1001)
108 !# 12:08 load MA mem (0000)
109 !# 07:00 length = 63
110
111 wr %g0, 0x40, %asi
112 setx 0x2003f, %g1, %g3
113 ldxa [%g0]0x63, %g1 ! get my TID for interrupt steering ..
114 sllx %g1, 18, %g1
115 or %g3, %g1, %g3
116 stxa %g3, [%g0 + 0x80] %asi
117
118
119 mov 100, %g1
120wait_for_int:
121 brnz,a %g1, wait_for_int
122 dec %g1
123
124halt1:
125 rdhpr %halt, %g7
126 wrpr %g0, 0x2, %pstate ! enable IE
127
128
129 ! Finish if not MT
130 brz %l1, done_thread
131 nop
132
133 ! If MT, shift mask, unpark next thread and finish
134 ldx [%l4], %l3
135 sllx %l3, 1, %l3
136 mov 0x60, %g1
137 stxa %l3, [%g1]0x41
138 stx %l3, [%l4]
139 nop
140
141
142/*******************************************************
143 * Exit code
144 *******************************************************/
145
146done_thread:
147 nop
148 ta T_GOOD_TRAP
149 nop
150
151/************************************************************************
152 Test case data start
153 ************************************************************************/
154.data
155is_mt :
156.xword 0x0
157park_mask:
158.xword 0x1
159mutex:
160.xword 0
161.end