Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * OpenSPARC T2 Processor File: tso_n2_prod_cons_intr4.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 BUFFERSIZE 64 /*in bytes*/ | |
40 | #define myIdReg %o0 | |
41 | #define phyCoreIdReg %o1 | |
42 | #define thrdIdReg %o2 | |
43 | #define ITERATIONS 0x4 | |
44 | #define bufferSizeReg %g1 | |
45 | #define prodCntReg %g2 | |
46 | #define consCntReg %g3 | |
47 | #define ASI_SWVR_UDB_INTR_W 0x73 | |
48 | #define ASI_SWVR_UDB_INTR_R 0x74 | |
49 | ||
50 | #define H_HT0_Interrupt_0x60 | |
51 | #define My_HT0_Interrupt_0x60 \ | |
52 | call My_interrupt_0x60_handler; \ | |
53 | nop; \ | |
54 | nop; \ | |
55 | nop; | |
56 | ||
57 | #include "hboot.s" | |
58 | ||
59 | .global main | |
60 | ||
61 | main: | |
62 | ta T_CHANGE_HPRIV ! change to hyper mode | |
63 | nop | |
64 | mov BUFFERSIZE, %g1 !Bounded Buffer Size | |
65 | mov ITERATIONS, prodCntReg !no of iterations to produce | |
66 | mov ITERATIONS, consCntReg !no of iterations to produce | |
67 | setx boundedBufferSize, %g5, %g6 | |
68 | mov 0x40, %g7 | |
69 | st %g7, [%g6] | |
70 | setx prodCnt, %g5, %g6 | |
71 | mov 0x04, %g7 | |
72 | st %g7, [%g6] | |
73 | setx consCnt, %g5, %g6 | |
74 | mov 0x04, %g7 | |
75 | st %g7, [%g6] | |
76 | setx consumedData, %g5, %g6 | |
77 | mov 0x0, %g7 | |
78 | st %g7, [%g6] | |
79 | setx producedData, %g5, %g6 | |
80 | mov 0x0, %g7 | |
81 | st %g7, [%g6] | |
82 | ||
83 | ||
84 | th_fork(th_main,%l0) | |
85 | ||
86 | ! Some of the threads are producers, some are consumers | |
87 | ! A pair of producer and consumer has the same ID. | |
88 | !===================================================== | |
89 | th_main_0: | |
90 | add %g0, 0x1, myIdReg ! this is my ID address | |
91 | add %g0, 0x0, phyCoreIdReg | |
92 | add %g0, 0x0, thrdIdReg | |
93 | ba producer | |
94 | nop | |
95 | ||
96 | th_main_1: | |
97 | add %g0, 0x1, myIdReg | |
98 | add %g0, 0x0, phyCoreIdReg | |
99 | add %g0, 0x1, thrdIdReg | |
100 | ba consumer | |
101 | nop | |
102 | ||
103 | th_main_2: | |
104 | add %g0, 0x3, myIdReg | |
105 | add %g0, 0x0, phyCoreIdReg | |
106 | add %g0, 0x2, thrdIdReg | |
107 | ||
108 | setx dataBufferBase, %l0, %l1 | |
109 | setx consCnt, %l0, %l2 | |
110 | setx boundedBufferSize, %l0, %l3 | |
111 | lduw [%l3], %l3 | |
112 | mov 0x0, %l4 | |
113 | mov 0x10, %l5 !stride | |
114 | ||
115 | noise1: | |
116 | lduw [%l2], %l6 | |
117 | subcc %l6, 0x2, %g0 | |
118 | bz noiseDone | |
119 | nop | |
120 | ldx [%l1 + %l4], %l7 | |
121 | add %l4, %l5, %l4 | |
122 | subcc %l4, %l3, %g0 | |
123 | bz,a wrapAround | |
124 | mov 0x0, %l4 | |
125 | wrapAround: | |
126 | ba noise1 | |
127 | nop | |
128 | noiseDone: | |
129 | call goodEnd | |
130 | nop | |
131 | ||
132 | th_main_3: | |
133 | add %g0, 0x2, myIdReg | |
134 | add %g0, 0x0, phyCoreIdReg | |
135 | add %g0, 0x3, thrdIdReg | |
136 | ! ba producer | |
137 | ! nop | |
138 | call goodEnd | |
139 | nop | |
140 | ||
141 | th_main_4: | |
142 | add %g0, 0x0, myIdReg | |
143 | add %g0, 0x0, phyCoreIdReg | |
144 | add %g0, 0x4, thrdIdReg | |
145 | ! ba consumer | |
146 | ! nop | |
147 | call goodEnd | |
148 | nop | |
149 | ||
150 | th_main_5: | |
151 | add %g0, 0x1, myIdReg | |
152 | add %g0, 0x0, phyCoreIdReg | |
153 | add %g0, 0x5, thrdIdReg | |
154 | ! ba producer | |
155 | ! nop | |
156 | call goodEnd | |
157 | nop | |
158 | ||
159 | th_main_6: | |
160 | add %g0, 0x3, myIdReg | |
161 | add %g0, 0x0, phyCoreIdReg | |
162 | add %g0, 0x6, thrdIdReg | |
163 | ! ba consumer | |
164 | ! nop | |
165 | call goodEnd | |
166 | nop | |
167 | ||
168 | th_main_7: | |
169 | add %g0, 0x2, myIdReg | |
170 | add %g0, 0x0, phyCoreIdReg | |
171 | add %g0, 0x7, thrdIdReg | |
172 | ! ba consumer | |
173 | ! nop | |
174 | call goodEnd | |
175 | nop | |
176 | ||
177 | goodEnd: | |
178 | ta T_GOOD_TRAP | |
179 | ||
180 | !============================================================== | |
181 | !Producer code | |
182 | !============================================================== | |
183 | producer: | |
184 | nop | |
185 | wakeProducer: | |
186 | setx prodCnt , %l0, %l2 | |
187 | lduw [%l2], %l3 | |
188 | subcc %l3, 0x1, %l3 | |
189 | subcc %l3, %g0, %g0 | |
190 | bz productionComplete | |
191 | st %l3, [%l2] | |
192 | ||
193 | call produceData !will produce one set of data | |
194 | nop | |
195 | ||
196 | !dispatch interrupt | |
197 | setx 0x102, %g6, %g7 ! send to thread 1 vector number 1 | |
198 | stxa %g7, [%g0]ASI_SWVR_UDB_INTR_W ! no membar sync needed after this reg | |
199 | ||
200 | ||
201 | snoozeProducer: | |
202 | setx consumedData, %l0, %l2 | |
203 | lduw [%l2], %l4 | |
204 | subcc %l4, 1, %l4 | |
205 | bz,a wakeProducer | |
206 | st %g0, [%l2] | |
207 | ba snoozeProducer | |
208 | nop | |
209 | ||
210 | productionComplete: | |
211 | ta T_GOOD_TRAP | |
212 | ||
213 | !produce data function | |
214 | produceData: | |
215 | save | |
216 | !find the buffer size | |
217 | setx dataBufferBase, %l0, %l1 | |
218 | setx boundedBufferSize , %l0, %l2 | |
219 | lduw [%l2] , %l0 !has buffer size | |
220 | mov %g0, %l4 | |
221 | !pair id available in global myIdReg | |
222 | umul %i0, %l0, %l3 | |
223 | add %l3, %l1, %l1 !has the base addr for this pair | |
224 | ||
225 | dataProduction: | |
226 | mov %i0, %l5 !after save o0 becomes i0 | |
227 | sllx %l5, 16, %l5 | |
228 | or %l5, %l4, %l5 | |
229 | stx %l5, [%l1 + %l4] | |
230 | subcc %l4, %l0, %g0 | |
231 | add %l4, 8, %l4 | |
232 | bnz,a dataProduction | |
233 | ldx [%l1 + %l4], %g0 | |
234 | dataProductionDone: | |
235 | restore | |
236 | retl | |
237 | nop | |
238 | ||
239 | ||
240 | !============================================================== | |
241 | !ConsumerCode: | |
242 | !============================================================== | |
243 | consumer: | |
244 | nop | |
245 | snoozeConsumer: | |
246 | setx producedData, %l0, %l2 | |
247 | lduw [%l2], %l4 | |
248 | subcc %l4, 1, %l4 | |
249 | bz,a wakeConsumer | |
250 | st %g0, [%l2] | |
251 | ba snoozeConsumer | |
252 | nop | |
253 | ||
254 | wakeConsumer: | |
255 | setx consCnt , %l0, %l2 | |
256 | lduw [%l2], %l3 | |
257 | subcc %l3, 0x1, %l3 | |
258 | subcc %l3, 0x1, %g0 | |
259 | bz consumeComplete | |
260 | st %l3, [%l2] | |
261 | ||
262 | call consumeData | |
263 | nop | |
264 | ||
265 | !dispacth interrrupt to producer | |
266 | mov 0x001, %g7 ! send to thread 0 vector number 1 | |
267 | stxa %g7, [%g0]ASI_SWVR_UDB_INTR_W ! no membar sync needed after this reg | |
268 | ||
269 | ba snoozeConsumer | |
270 | nop | |
271 | consumeComplete: | |
272 | mov 0x001, %g7 ! send to thread 0 vector number 1 | |
273 | stxa %g7, [%g0]ASI_SWVR_UDB_INTR_W ! no membar sync needed after this reg | |
274 | ta T_GOOD_TRAP | |
275 | ||
276 | !consume data function | |
277 | consumeData: | |
278 | save | |
279 | !find the buffer size | |
280 | setx dataBufferBase, %l0, %l1 | |
281 | setx boundedBufferSize , %l0, %l2 | |
282 | lduw [%l2] , %l0 !has buffer size | |
283 | mov %g0, %l4 | |
284 | !pair id available in global myIdReg | |
285 | umul %i0, %l0, %l3 | |
286 | add %l3, %l1, %l1 !has the base addr for this pair | |
287 | ||
288 | consumingData: | |
289 | mov %i0, %l5 | |
290 | sllx %l5, 16, %l5 | |
291 | or %l5, %l4, %l5 | |
292 | ldx [%l1 + %l4], %l6 | |
293 | subcc %l6, %l5, %l6 | |
294 | bnz badDataConsumed | |
295 | nop | |
296 | subcc %l4, %l0, %g0 | |
297 | add %l4, 0x8, %l4 | |
298 | bnz,a consumingData | |
299 | ldx [%l1 + %l4], %g0 | |
300 | consumeDone: | |
301 | restore | |
302 | retl | |
303 | nop | |
304 | ||
305 | badDataConsumed: | |
306 | ta T_BAD_TRAP | |
307 | ||
308 | ||
309 | !============================================================== | |
310 | !interrupt handler | |
311 | !============================================================== | |
312 | .global My_interrupt_0x60_handler | |
313 | My_interrupt_0x60_handler: | |
314 | !First figure out wether the consumer interrupting producer | |
315 | !or Producer interrupting Consumer | |
316 | !if the vector is 1 then consumer interrupting producer | |
317 | !if the vector is 2 then producer interrupting consumer | |
318 | !In interrupts Interrupt Globals are used IG | |
319 | ||
320 | !read the ASI_SWVR_UDB_INTR_R ASI=0x74 VA=0x0 | |
321 | ldxa [%g0]0x74, %g1 | |
322 | subcc %g1, 0x1, %g0 | |
323 | bz consumerToProducer | |
324 | nop | |
325 | subcc %g1, 0x2, %g0 | |
326 | bz producerToConsumer | |
327 | consumerToProducer: | |
328 | setx consumedData, %l0, %g2 | |
329 | mov 0x1, %g3 | |
330 | st %g3, [%g2] | |
331 | ba returnToSnooze | |
332 | nop | |
333 | ||
334 | producerToConsumer: | |
335 | setx producedData, %l0, %g2 | |
336 | mov 0x1, %g3 | |
337 | st %g3, [%g2] | |
338 | ba returnToSnooze | |
339 | nop | |
340 | ||
341 | returnToSnooze: | |
342 | retry | |
343 | nop | |
344 | ||
345 | !=============================================================== | |
346 | SECTION .MY_DATA0 TEXT_VA=0xf0100000, DATA_VA=0xd0100000 | |
347 | attr_data { | |
348 | Name = .MY_DATA0, | |
349 | VA= 0x0d0100000 | |
350 | RA= 0x1d0100000 | |
351 | PA= ra2pa(0x1d0100000,0), | |
352 | part_0_ctx_nonzero_tsb_config_0, | |
353 | TTE_G=1, TTE_Context=0x44, TTE_V=1, TTE_Size=0, TTE_NFO=0, | |
354 | TTE_IE=0, TTE_Soft2=0, TTE_Diag=0, TTE_Soft=0, | |
355 | TTE_L=0, TTE_CP=1, TTE_CV=1, TTE_E=0, TTE_P=0, TTE_W=1 | |
356 | } | |
357 | ||
358 | attr_text { | |
359 | Name = .MY_DATA0, | |
360 | VA= 0x0f0100000 | |
361 | RA= 0x1f0100000 | |
362 | PA= ra2pa(0x1f0100000,0), | |
363 | part_0_ctx_nonzero_tsb_config_0, | |
364 | TTE_G=1, TTE_Context=0x44, TTE_V=1, TTE_Size=0, TTE_NFO=0, | |
365 | TTE_IE=0, TTE_Soft2=0, TTE_Diag=0, TTE_Soft=0, | |
366 | TTE_L=0, TTE_CP=1, TTE_CV=1, TTE_E=0, TTE_P=0, TTE_W=1 | |
367 | } | |
368 | ||
369 | ||
370 | .data | |
371 | .global parameters | |
372 | parameters: | |
373 | .word 0x0 | |
374 | .global boundedBufferSize | |
375 | boundedBufferSize: | |
376 | .word 0x40 | |
377 | .global prodCnt | |
378 | prodCnt: | |
379 | .word 0x4 | |
380 | .global consCnt | |
381 | consCnt: | |
382 | .word 0x4 | |
383 | .global consumedData | |
384 | consumedData: | |
385 | .word 0x0 | |
386 | .global producedData | |
387 | producedData: | |
388 | .word 0x0 | |
389 | strnId0: | |
390 | .word 0x1 | |
391 | strnId1: | |
392 | .word 0x1 | |
393 | strnId2: | |
394 | .word 0x0 | |
395 | strnId3: | |
396 | .word 0x0 | |
397 | strnId4: | |
398 | .word 0x0 | |
399 | strnId5: | |
400 | .word 0x0 | |
401 | strnId6: | |
402 | .word 0x0 | |
403 | strnId7: | |
404 | .word 0x0 | |
405 | .word 0x0 | |
406 | .word 0x0 | |
407 | .word 0x0 | |
408 | .word 0x0 | |
409 | .word 0x0 | |
410 | .word 0x0 | |
411 | .word 0x0 | |
412 | .word 0x0 | |
413 | .word 0x0 | |
414 | .word 0x0 | |
415 | .word 0x0 | |
416 | .word 0x0 | |
417 | .word 0x0 | |
418 | .word 0x0 | |
419 | .word 0x0 | |
420 | .word 0x0 | |
421 | .word 0x0 | |
422 | .word 0x0 | |
423 | .word 0x0 | |
424 | .word 0x0 | |
425 | .word 0x0 | |
426 | .word 0x0 | |
427 | .word 0x0 | |
428 | .word 0x0 | |
429 | .word 0x0 | |
430 | .word 0x0 | |
431 | .word 0x0 | |
432 | .word 0x0 | |
433 | .word 0x0 | |
434 | .word 0x0 | |
435 | .word 0x0 | |
436 | .word 0x0 | |
437 | .word 0x0 | |
438 | .word 0x0 | |
439 | .word 0x0 | |
440 | .word 0x0 | |
441 | .word 0x0 | |
442 | .word 0x0 | |
443 | .word 0x0 | |
444 | .word 0x0 | |
445 | .word 0x0 | |
446 | .word 0x0 | |
447 | .word 0x0 | |
448 | .word 0x0 | |
449 | .word 0x0 | |
450 | .word 0x0 | |
451 | .word 0x0 | |
452 | .word 0x0 | |
453 | .word 0x0 | |
454 | .word 0x0 | |
455 | .word 0x0 | |
456 | .word 0x0 | |
457 | .word 0x0 | |
458 | .word 0x0 | |
459 | .word 0x0 | |
460 | .word 0x0 | |
461 | .word 0x0 | |
462 | .word 0x0 | |
463 | .word 0x0 | |
464 | .word 0x0 | |
465 | .word 0x0 | |
466 | .word 0x0 | |
467 | .word 0x0 | |
468 | .word 0x0 | |
469 | .word 0x0 | |
470 | .word 0x0 | |
471 | .word 0x0 | |
472 | .word 0x0 | |
473 | .word 0x0 | |
474 | .word 0x0 | |
475 | .word 0x0 | |
476 | ||
477 | SECTION .MY_DATA1 TEXT_VA=0xf1110000, DATA_VA=0xd1110000 | |
478 | attr_data { | |
479 | Name = .MY_DATA1, | |
480 | VA= 0x0d1110000, | |
481 | RA= 0x1d1110000, | |
482 | PA= ra2pa(0x1d1110000,0), | |
483 | part_0_ctx_nonzero_tsb_config_0, | |
484 | TTE_G=1, TTE_Context=0x44, TTE_V=1, TTE_Size=0, TTE_NFO=0, | |
485 | TTE_IE=0, TTE_Soft2=0, TTE_Diag=0, TTE_Soft=0, | |
486 | TTE_L=0, TTE_CP=1, TTE_CV=1, TTE_E=0, TTE_P=0, TTE_W=1 | |
487 | } | |
488 | ||
489 | attr_text { | |
490 | Name = .MY_DATA1, | |
491 | VA= 0x0f1110000, | |
492 | RA= 0x1f1110000, | |
493 | PA= ra2pa(0x1f1110000,0), | |
494 | part_0_ctx_nonzero_tsb_config_0, | |
495 | TTE_G=1, TTE_Context=0x44, TTE_V=1, TTE_Size=0, TTE_NFO=0, | |
496 | TTE_IE=0, TTE_Soft2=0, TTE_Diag=0, TTE_Soft=0, | |
497 | TTE_L=0, TTE_CP=1, TTE_CV=1, TTE_E=0, TTE_P=0, TTE_W=1 | |
498 | } | |
499 | ||
500 | ||
501 | .data | |
502 | .global dataBufferBase | |
503 | dataBufferBase: | |
504 | .word 0xbeef | |
505 | .skip 0x1000 | |
506 | .word 0xbeef | |
507 | .end |