Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / diag / assembly / arch / prm / interrupt / interrupt_ether_receive.s
CommitLineData
86530b38
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: interrupt_ether_receive.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#define H_HT0_Interrupt_0x60
41#define My_HT0_Interrupt_0x60 \
42 call my_trap_code; \
43 nop; \
44 retry; \
45 nop;
46
47
48#include "hboot.s"
49#include "niu_defines.h"
50#include "ncu_defines.h"
51#include "niu_macros.h"
52
53/************************************************************************
54 Test case code start
55 ************************************************************************/
56
57.text
58.global main
59
60main:
61 ta T_CHANGE_HPRIV
62 nop
63 ta T_CHANGE_PRIV
64 nop
65
66/* Initialize the NCU for the interrupt. */
67
68 ! Disable interrupts
69
70no_intr:
71 rdpr %pstate, %g7
72 xor %g7, 0x2, %g7 ! Reset interrupt enable
73 wrpr %g7, %pstate
74
75ncu_init:
76 ! Initially set all the Interrupt Management Registers
77 ! Later will set all those not used to have a different vector number
78
79 setx INT_MAN, %g1, %g2 ! %g2 = INT_MAN reg. addr.
80 setx INT_MAN_COUNT, %g1, %g4 ! %g4 = INT_MAN reg. count value
81 set 1, %g5 ! %g5 = value to write to INT_MAN reg.
82
83niu_init_loop_top:
84 stx %g5, [%g2]
85 add %g2, INT_MAN_STEP, %g2
86 cmp %g4, 1
87 bne niu_init_loop_top
88 add %g4, -1, %g4
89
90 ! Enable interrupts
91
92yes_intr:
93 rdpr %pstate, %g7
94 or %g7, 0x2, %g7 ! Set interrupt enable
95 wrpr %g7, %pstate
96
97 ! Kick off an interrupt, by simply starting up the RX channel
98 ! There is a config. error that will cause the interrupt.
99
100reset_rx:
101 setx RXDMA_CFIG1, %g1, %g2 ! using Rx DMA channel 0
102
103 ! First 0 -> EN of RXDMA_CFIG1
104
105 stxa %g0, [%g2]ASI_PRIMARY_LITTLE
106 membar #Sync
107
108 ! Next do the reset, 1 -> RST of RXDMA_CFIG1
109
110 setx 0x40000000, %g1, %g3
111 stxa %g3, [%g2]ASI_PRIMARY_LITTLE ! Reset the channel
112 membar #Sync
113
114 ! Wait for reset to be over
115
116reset_rx_wait:
117 setx 0x80, %g1, %g4 ! timeout value
118 setx 0x20000000, %g1, %g3 ! QST bit in RXDMA_CFIG1
119
120reset_rx_wait_loop:
121 ldxa [%g2]ASI_PRIMARY_LITTLE, %g1
122 cmp %g1, %g3 ! Look for QST 1, RST 0
123 beq config_rx
124 dec %g4
125 cmp %g4, 0
126 beq local_test_failed
127 nop
128
129 ! Now the DMA channel can be configured
130
131config_rx:
132 NIU_RX_DMA_INTR_ON_CFIGLOGPAGE(0, 0, 64, %i1, %i2, %i3, %i4)
133
134 ! Finally the RX DMA channel can be enabled.
135
136enable_rx:
137 setx 0x80000000, %g1, %g3 ! EN bit in RXDMA_CFIG1
138 stxa %g3, [%g2]ASI_PRIMARY_LITTLE ! Enable the channel
139 membar #Sync
140
141
142 ! Has an interrupt occured
143intr_check:
144 setx 0x100, %g1, %6
145 setx user_data_start, %g1, %g2
146
147intr_check_loop:
148 ld [%g2], %g7
149 cmp %g7, 1
150 be test_passed
151 nop
152 cmp %g6, 0
153 bgt intr_check_loop
154 dec %g6
155
156 ! Done registers to see current state if failed.
157bad_bad:
158 setx RX_DMA_CTL_STAT_DBG, %g1, %g2
159 ldxa [%g2]ASI_PRIMARY_LITTLE, %o1
160 setx RX_DMA_CTL_STAT, %g1, %g2
161 ldxa [%g2]ASI_PRIMARY_LITTLE, %o2
162 setx RXDMA_CFIG2_Addr, %g1, %g2
163 ldxa [%g2]ASI_PRIMARY_LITTLE, %o3
164 setx RXDMA_CFIG1_Addr, %g1, %g2
165 ldxa [%g2]ASI_PRIMARY_LITTLE, %o4
166 setx RX_DMA_ENT_MSK, %g1, %g2
167 ldxa [%g2]ASI_PRIMARY_LITTLE, %o5
168 setx SID, %g1, %g2
169 ldxa [%g2]ASI_PRIMARY_LITTLE, %o6
170 setx LDGITMRES, %g1, %g2
171 ldxa [%g2]ASI_PRIMARY_LITTLE, %o7
172 setx LDGIMGN, %g1, %g2
173 ldxa [%g2]ASI_PRIMARY_LITTLE, %i1
174 setx LDG_NUM, %g1, %g2
175 ldxa [%g2]ASI_PRIMARY_LITTLE, %i2
176 setx LD_IM0, %g1, %g2
177 ldxa [%g2]ASI_PRIMARY_LITTLE, %i3
178 setx LDSV0, %g1, %g2
179 ldxa [%g2]ASI_PRIMARY_LITTLE, %i4
180 setx LDSV1, %g1, %g2
181 ldxa [%g2]ASI_PRIMARY_LITTLE, %i5
182 membar #Sync
183
184 ba local_test_failed
185 nop
186
187
188/**********************************************************************
189 Interrupt trap handler.
190**********************************************************************/
191
192.global my_trap_code
193
194my_trap_code:
195
196 setx user_data_start, %l2, %l6
197
198 ! Increment the count
199Trap1:
200 ld [%l6], %l5
201 add %l5, 1, %l5
202 st %l5, [%l6]
203 membar #Sync
204
205 ! Clear the interrupt
206Trap2:
207 ldxa [%g0]ASI_SWVR_INTR_R, %l3
208
209 jmpl %o7+0x8, %g0
210 nop
211
212
213
214test_passed:
215 nop
216 EXIT_GOOD
217
218
219local_test_failed:
220 EXIT_BAD
221
222
223/************************************************************************
224 Test case data start
225 ************************************************************************/
226
227.align 1024
228.data
229.global mailbox
230user_data_start:
231 .word 0x0, 0x0
232
233.align 64
234mailbox: .skip 1024
235
236user_data_end:
237