Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * OpenSPARC T2 Processor File: interrupt_niurx.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 ENABLE_BG_NIU_RX 1 | |
41 | #define ENABLE_NIU_BACKGROUND_PACKETS_IN_BOOT 1 | |
42 | ||
43 | #define ENABLE_INTR0x60 1 | |
44 | ||
45 | #define INTR0x60_INITIALIZE_INT_MAN 1 | |
46 | ||
47 | #define INTR0x60_NIU_RX_IV_0 7 | |
48 | #define INTR0x60_NIU_RX_THREAD_0 1 | |
49 | #define INTR0x60_NIU_RX_DMA_0 0 | |
50 | ||
51 | #include "niu_defines.h" | |
52 | ||
53 | /* Increment the interrupt count for this thread. | |
54 | * If it is not equal to the expected count, call NIU_PktRcv. | |
55 | * The call instruction will write to %o7, so preserve it in %g7 */ | |
56 | #define INTR0x60_NIU_RX_EXTRA_HANDLER \ | |
57 | setx intr_count, %g7, %g6; \ | |
58 | add %g6, %g1, %g6; \ | |
59 | ldub [%g6], %g5; \ | |
60 | inc %g5; \ | |
61 | stb %g5, [%g6]; \ | |
62 | setx intr_expect, %g7, %g6; \ | |
63 | add %g6, %g1, %g6; \ | |
64 | ldub [%g6], %g7; \ | |
65 | cmp %g7, %g5; \ | |
66 | be %xcc, 1f; \ | |
67 | mov %o7, %g7; \ | |
68 | call NIU_PktRcv; nop; \ | |
69 | mov %g7, %o7; \ | |
70 | 1: | |
71 | ||
72 | #include "interrupt0x60_defines.h" | |
73 | ||
74 | ||
75 | #define SYNC_THREADS 1 | |
76 | ||
77 | #include "hboot.s" | |
78 | ||
79 | #include "interrupt0x60_handler.s" | |
80 | ||
81 | ||
82 | #include "niu_pktgen.s" | |
83 | ||
84 | /************************************************************************ | |
85 | Test case code start | |
86 | ************************************************************************/ | |
87 | SECTION .MAIN | |
88 | .text | |
89 | .global main | |
90 | ||
91 | main: | |
92 | ta T_CHANGE_HPRIV | |
93 | ||
94 | get_thread_id: | |
95 | ldxa [%g0] ASI_INTR_ID, %g1 ! Get the thread number | |
96 | brz %g1, t0_main | |
97 | nop | |
98 | ba intr_wait | |
99 | nop | |
100 | ||
101 | /**************************************************************/ | |
102 | /* Thread 0 */ | |
103 | t0_main: | |
104 | nop | |
105 | /* Interrupts are now started in niu_start_bg_pkts.s */ | |
106 | ||
107 | /* We are all done sending interrupts, so go to the wait loop */ | |
108 | ba intr_wait | |
109 | nop | |
110 | ||
111 | ||
112 | /**************************************************************/ | |
113 | /* Common wait loop for all threads */ | |
114 | intr_wait: | |
115 | setx intr_expect, %l1, %g4 | |
116 | add %g4, %g1, %g4 ! address of expected interrupt count for this thread | |
117 | ldub [%g4], %g4 | |
118 | ||
119 | setx intr_count, %l1, %g3 | |
120 | add %g3, %g1, %g3 ! address of interrupt count for this thread | |
121 | ||
122 | best_set_reg(100, %l1, %g2) ! timeout count | |
123 | ||
124 | intr_wait_loop_top: | |
125 | /* For debug, get the values of certain NIU registers */ | |
126 | best_set_reg(mpeval(RX_DMA_CTL_STAT_DBG+(RXDMA_CHNL*RX_DMA_CTL_STAT_STEP)), | |
127 | %l1, %l0) | |
128 | ldxa [%l0]ASI_PRIMARY_LITTLE, %l5 | |
129 | best_set_reg(mpeval(RX_DMA_CTL_STAT+(RXDMA_CHNL*RX_DMA_CTL_STAT_STEP)), | |
130 | %l1, %l0) | |
131 | ldxa [%l0]ASI_PRIMARY_LITTLE, %l6 | |
132 | best_set_reg(mpeval(RCR_STAT_A+(RXDMA_CHNL*RX_DMA_CTL_STAT_STEP)), | |
133 | %l1, %l0) | |
134 | ldxa [%l0]ASI_PRIMARY_LITTLE, %l7 | |
135 | ||
136 | /* Check whether we have received the desired number of interrupts */ | |
137 | ldub [%g3], %g5 | |
138 | cmp %g5, %g4 | |
139 | be thread_passed | |
140 | dec %g2 | |
141 | ||
142 | cmp %g2, 0 | |
143 | bne intr_wait_loop_top | |
144 | nop | |
145 | ||
146 | intr_timeout: | |
147 | !$EV trig_pc_d(1, @VA(.MAIN.intr_timeout)) -> printf("ERROR: Timeout waiting for interrupt",*,1) | |
148 | EXIT_BAD | |
149 | ||
150 | thread_passed: | |
151 | EXIT_GOOD | |
152 | ||
153 | local_test_failed: | |
154 | EXIT_BAD | |
155 | ||
156 | ||
157 | ||
158 | /************************************************************************ | |
159 | Test case data start | |
160 | ************************************************************************/ | |
161 | ||
162 | .align 1024 | |
163 | .data | |
164 | user_data_start: | |
165 | user_data_end: | |
166 | ||
167 | ||
168 | SECTION .HTRAPS | |
169 | .data | |
170 | .global intr_count | |
171 | intr_count: | |
172 | .byte 0x0 ! interrupt count for thread 0 | |
173 | .byte 0x0 ! interrupt count for thread 1 | |
174 | .byte 0x0 ! interrupt count for thread 2 | |
175 | .byte 0x0 ! interrupt count for thread 3 | |
176 | .byte 0x0 ! interrupt count for thread 4 | |
177 | .byte 0x0 ! interrupt count for thread 5 | |
178 | .byte 0x0 ! interrupt count for thread 6 | |
179 | .byte 0x0 ! interrupt count for thread 7 | |
180 | ||
181 | .global intr_expect | |
182 | intr_expect: | |
183 | .byte 0x0 ! expected interrupt count for thread 0 | |
184 | .byte 0x3 ! expected interrupt count for thread 1 | |
185 | .byte 0x0 ! expected interrupt count for thread 2 | |
186 | .byte 0x0 ! expected interrupt count for thread 3 | |
187 | .byte 0x0 ! expected interrupt count for thread 4 | |
188 | .byte 0x0 ! expected interrupt count for thread 5 | |
189 | .byte 0x0 ! expected interrupt count for thread 6 | |
190 | .byte 0x0 ! expected interrupt count for thread 7 | |
191 | .end | |
192 | ||
193 | /************************************************************************/ |