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