Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / diag / assembly / niu / NIU_Tx_Rx / txrxrand_1.s
CommitLineData
86530b38
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: txrxrand_1.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#define RCRSTAT_A_Addr mpeval(DMC_ADDRESS_RANGE+0x00050)
40#define RBR_STAT_Addr mpeval(DMC_ADDRESS_RANGE+0x00028)
41
42#include "hboot.s"
43#include "niu_defines.h"
44.text
45.global main
46main:
47 ta T_CHANGE_HPRIV
48 nop
49! branch to main by comparing thread id.
50
51 ta T_RD_THID
52 mov 0x1, %g2
53
54 setx 0x0000000000000001, %o0, %g3 ! thread-group bits for the template
55 cmp %g2, %o1
56 be _FcN1_main
57 nop
58
59 setx 0x0000000000000010, %o0, %g3 ! thread-group bits for the template
60 brz %o1, _FcN0_main
61 mov 0x2, %g2
62 and %o1, %g3, %g1
63 nop
64
65!
66! Thread 0 Start
67!
68!
69_FcN0_main:
70
71# 150 "diag.j"
72
73
74Init_flow:
75 nop ! $EV trig_pc_d(1, @VA(.MAIN.Init_flow)) -> pktGenConfig(MAC_ID, FRAME_TYPE, FRAME_CLASS, 64)
76
77P_TxDMAActivate:
78 setx MAC_ID, %g1, %o0
79 setx 0x1, %g1, %o1
80 call SetTxDMAActive
81 nop ! $EV trig_pc_d(1, @VA(.MAIN.P_TxDMAActivate)) -> NIU_TxDMAActivate (MAC_ID, 1)
82 setx XMAC0_MAX_addr, %g7, %g2
83
84
85P_AddTxChannels:
86 nop ! $EV trig_pc_d(1, @VA(.MAIN.P_AddTxChannels)) -> NIU_AddTxChannels(MAC_ID, 0)
87 ldxa [%g2]ASI_PRIMARY_LITTLE, %g5
88 nop
89
90P_SetTxMaxBurst:
91 setx 0x0, %g1, %o0
92 setx SetTxMaxBurst_Data, %g1, %o1
93 call SetTxMaxBurst
94 nop ! $EV trig_pc_d(1, @VA(.MAIN.P_SetTxMaxBurst)) -> NIU_SetTxMaxBurst (MAC_ID, 0, TxMaxBurst_Data)
95 ldxa [%g2]ASI_PRIMARY_LITTLE, %g5
96 nop
97
98P_InitTxDma:
99 setx 0x0, %g1, %o0
100 nop ! $EV trig_pc_d(1, @VA(.MAIN.P_InitTxDma)) -> NIU_InitTxDma (MAC_ID, 0, NIU_Xlate_On)
101 call InitTxDma
102 nop
103 ldxa [%g2]ASI_PRIMARY_LITTLE, %g5
104 nop
105
106Gen_Packet:
107 nop ! $EV trig_pc_d(1, @VA(.MAIN.Gen_Packet)) -> TxPktGen(MAC_ID, 0, 0x9c,0,0,0, 1)
108 nop
109
110 setx 0x5, %g1, %g4
111delay_loop_tmp:
112 ldxa [%g2]ASI_PRIMARY_LITTLE, %g5
113 nop
114 nop
115 nop
116 nop
117 dec %g4
118 brnz %g4, delay_loop_tmp
119 nop
120
121SetTxRingKick:
122 setx NIU_PKTGEN_CSR_EV2A_TX_RNG_KICK, %g1, %g2 ! $EV trig_pc_d(1, @VA(.MAIN.SetTxRingKick)) -> NIU_SetTxRingKick(MAC_ID, 0)
123 setx 0x0, %g1, %o0
124 ldx [%g2] , %g3
125 nop
126 mulx %o0, 0x200, %g5
127 setx TX_RING_KICK_Addr, %g1, %g2
128 add %g2, %g5, %g2
129 stxa %g3, [%g2]ASI_PRIMARY_LITTLE
130 nop
131
132SetTxCs:
133 setx 0x0, %g1, %o0
134 setx TX_CS_Data, %g1, %g3
135 mulx %o0, 0x200, %g5
136 setx TX_CS_Addr, %g1, %g2
137 add %g2, %g5, %g2
138 stxa %g3, [%g2]ASI_PRIMARY_LITTLE
139 nop
140
141#ifdef JUMBO_FRAME_EN
142 setx loop_count, %g1, %g4
143delay_loop:
144 ldxa [%g2]ASI_PRIMARY_LITTLE, %g5
145 nop
146 nop
147 nop
148 nop
149 dec %g4
150 brnz %g4, delay_loop
151 nop
152#endif
153
154
155NIUTx_Pkt_Cnt_Chk:
156 setx MAC_ID, %g1, %o0
157 setx 0x9c, %g1, %o1
158 call NiuTx_check_pkt_cnt
159 nop
160
161 setx loop_count, %g1, %g4
162delay_loop_end:
163 ldxa [%g2]ASI_PRIMARY_LITTLE, %g5
164 nop
165 nop
166 nop
167 nop
168 dec %g4
169 brnz %g4, delay_loop_end
170 nop
171
172test_passed_tx:
173 nop ! $EV trig_pc_d(1, @VA(.MAIN.test_passed_tx)) -> NIU_EXIT_chk(MAC_ID)
174 EXIT_GOOD
175
176_FcN1_main:
177P_NIU_RxInitDma:
178 nop ! $EV trig_pc_d(1, @VA(.MAIN.P_NIU_RxInitDma)) -> NIU_InitRxDma(a, RX_DESC_RING_LENGTH, RX_COMPL_RING_LEN, RBR_CONFIG_B_DATA, RX_INITIAL_KICK, NIU_Xlate_On, RX_NIU_MULTI_DMA)
179 setx NIU_PKTGEN_CSR_EV2A_RBR_KICK, %g7, %g2
180delay_loop_Rx:
181 ldx [%g2] , %g5
182 cmp %g5, RX_INITIAL_KICK
183 bne delay_loop_Rx
184 nop
185 nop
186 nop
187
188 setx 0xa, %g1, %o0
189 setx RX_DESC_RING_LENGTH, %g1, %o1
190 setx RX_COMPL_RING_LEN, %g1, %o2
191 setx RBR_CONFIG_B_DATA, %g1, %o3
192 setx RX_INITIAL_KICK, %g1, %o4
193 call NiuInitRxDma
194 nop
195P_NIU_RxPkt_Conf:
196 nop ! $EV trig_pc_d(1, @VA(.MAIN.P_NIU_RxPkt_Conf)) -> NIU_RxPktConf(RXMAC_PKTCNT, MAC_ID)
197 ldxa [%g2]ASI_PRIMARY_LITTLE, %g5
198 nop
199 setx RXMAC_PKTCNT, %g1, %g6
200 mulx %o0, 0x200, %g5
201 setx RBR_STAT_Addr, %g7, %g2
202 add %g2, %g5, %g2
203P_NIU_Rx_GenPkt:
204 ldxa [%g2]ASI_PRIMARY_LITTLE, %g5
205 brz %g5, P_NIU_Rx_GenPkt
206 nop
207#ifdef NIU_SYSTEMC_T2
208 brnz %g5, Rx_pktcnt_loop
209 nop
210#endif
211 cmp %g5, %o4
212 be P_NIU_Rx_GenPkt
213 nop
214Rx_pktcnt_loop:
215 nop ! $EV trig_pc_d(1, @VA(.MAIN.Rx_pktcnt_loop)) -> NIU_RxGenPkt(MAC_ID, a, RXMAC_PKTCNT, 0x40,0x0, RX_NIU_MULTI_DMA, 1)
216 ldxa [%g2]ASI_PRIMARY_LITTLE, %g5
217 nop
218
219 mulx %o0, 0x200, %g5
220 setx RCRSTAT_A_Addr, %g7, %g2
221 add %g2, %g5, %g2
222delay_loop:
223 ldxa [%g2]ASI_PRIMARY_LITTLE, %g5
224 cmp %g5, RXMAC_PKTCNT - RXMAC_PKTCNT%8
225 bne delay_loop
226 nop
227test_passed:
228 nop
229 EXIT_GOOD
230
231#if 0
232#endif