Debian Codegraph @

tests/aslts/src/runtime/collections/mt/mutex/mxs.asl

raw
1 /*
2 * Some or all of this work - Copyright (c) 2006 - 2021, Intel Corp.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
7 *
8 * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * Neither the name of Intel Corporation nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28 /*
29 * Access to mutexes routines
30 */
31 Name (Z149, 0x95)
32 /*
33 * Opcodes of initialization of set of mutexes
34 *
35 * c300 - usual
36 * c301 - one mutex of Index equal to ((Index of current thread) - 1)
37 */
38 Name (C300, 0x00)
39 Name (C301, 0x01)
40 /*
41 * Flags corresponding to Mutexes
42 */
43 Name (FL00, Package (MAX0)
44 {
45 Package (MAX1){},
46 Package (MAX1){},
47 Package (MAX1){},
48 Package (MAX1){},
49 Package (MAX1){},
50 Package (MAX1){},
51 Package (MAX1){},
52 Package (MAX1){},
53 Package (MAX1){},
54 Package (MAX1){},
55 Package (MAX1){},
56 Package (MAX1){},
57 Package (MAX1){},
58 Package (MAX1){},
59 Package (MAX1){},
60 Package (MAX1){}
61 })
62 /*
63 * Counters (current) corresponding to Mutexes
64 * (how many times the relevant mutex has been
65 * successfully Acquired (may be repeatedly)
66 * (by the same thread))
67 *
68 * - incremented on Acquire
69 * - decremented on Release
70 */
71 Name (FL01, Package (MAX0)
72 {
73 Package (MAX1){},
74 Package (MAX1){},
75 Package (MAX1){},
76 Package (MAX1){},
77 Package (MAX1){},
78 Package (MAX1){},
79 Package (MAX1){},
80 Package (MAX1){},
81 Package (MAX1){},
82 Package (MAX1){},
83 Package (MAX1){},
84 Package (MAX1){},
85 Package (MAX1){},
86 Package (MAX1){},
87 Package (MAX1){},
88 Package (MAX1){}
89 })
90 /*
91 * Counters corresponding to Mutexes
92 *
93 * how many times the mutex has successfully Acquired
94 * by different threads.
95 *
96 * - incremented on Acquire
97 * - reset to zero by the Control thread
98 */
99 Name (CNT0, Package (MAX0)
100 {
101 Package (MAX1){},
102 Package (MAX1){},
103 Package (MAX1){},
104 Package (MAX1){},
105 Package (MAX1){},
106 Package (MAX1){},
107 Package (MAX1){},
108 Package (MAX1){},
109 Package (MAX1){},
110 Package (MAX1){},
111 Package (MAX1){},
112 Package (MAX1){},
113 Package (MAX1){},
114 Package (MAX1){},
115 Package (MAX1){},
116 Package (MAX1){}
117 })
118 /*
119 * Acquire mutex
120 *
121 * arg0 - ID of current thread
122 * arg1 - Index of thread
123 * arg2 - Level of mutex
124 * arg3 - Index of mutex
125 * arg4 - opcode of exception to be generated or zero
126 * arg5 - opcode of TimeOutValue (see comment to ma00)
127 * arg6 - if fall into sleep
128 */
129 Method (M310, 7, Serialized)
130 {
131 Local0 = M21E ("Acquire mutex, ", Arg2, Arg3)
132 M201 (Arg1, VB03, Local0)
133 /* Increment statistics of Acquire */
134
135 If (VB04)
136 {
137 M212 (RefOf (P105), Arg1)
138 }
139
140 If ((Arg4 == EX0D))
141 {
142 /* FAIL expected */
143
144 Local6 = 0x00
145 }
146 Else
147 {
148 Local6 = Arg4
149 }
150
151 Local7 = 0x01 /* Init with FAIL */
152 Switch (Arg2)
153 {
154 Case (0x00)
155 {
156 Local7 = MA00 (Arg3, Local6, Arg5)
157 }
158 Case (0x01)
159 {
160 Local7 = MA01 (Arg3, Local6, Arg5)
161 }
162 Case (0x02)
163 {
164 Local7 = MA02 (Arg3, Local6, Arg5)
165 }
166 Case (0x03)
167 {
168 Local7 = MA03 (Arg3, Local6, Arg5)
169 }
170 Case (0x04)
171 {
172 Local7 = MA04 (Arg3, Local6, Arg5)
173 }
174 Case (0x05)
175 {
176 Local7 = MA05 (Arg3, Local6, Arg5)
177 }
178 Case (0x06)
179 {
180 Local7 = MA06 (Arg3, Local6, Arg5)
181 }
182 Case (0x07)
183 {
184 Local7 = MA07 (Arg3, Local6, Arg5)
185 }
186 Case (0x08)
187 {
188 Local7 = MA08 (Arg3, Local6, Arg5)
189 }
190 Case (0x09)
191 {
192 Local7 = MA09 (Arg3, Local6, Arg5)
193 }
194 Case (0x0A)
195 {
196 Local7 = MA0A (Arg3, Local6, Arg5)
197 }
198 Case (0x0B)
199 {
200 Local7 = MA0B (Arg3, Local6, Arg5)
201 }
202 Case (0x0C)
203 {
204 Local7 = MA0C (Arg3, Local6, Arg5)
205 }
206 Case (0x0D)
207 {
208 Local7 = MA0D (Arg3, Local6, Arg5)
209 }
210 Case (0x0E)
211 {
212 Local7 = MA0E (Arg3, Local6, Arg5)
213 }
214 Case (0x0F)
215 {
216 Local7 = MA0F (Arg3, Local6, Arg5)
217 }
218
219 }
220
221 If ((Arg4 == EX0D))
222 {
223 /* FAIL expected */
224
225 If (Local7)
226 {
227 M201 (Arg1, VB03, "Acquire returned non-zero, it was expected")
228 }
229 Else
230 {
231 M201 (Arg1, VB03, "Error 9: Acquire returned zero but FAIL expected!")
232 SE00 (Arg1, ER09, "Error er09")
233 }
234
235 Return (Local7)
236 }
237 ElseIf (Arg4)
238 {
239 Return (0x01)
240 }
241 ElseIf (Local7)
242 {
243 M201 (Arg1, VB03, "Error 0: Acquire returned non-zero!")
244 SE00 (Arg1, ER00, "Error er00")
245 Return (0x01)
246 }
247 Else
248 {
249 /*
250 * Increment counter (cnt0) and set up flag (fl00)
251 * corresponding to mutex. Report error in case the
252 * flag is non-zero.
253 */
254 Local7 = M21E ("Incrementing count of mutex, ", Arg2, Arg3)
255 Concatenate (Local7, " and set up its flag", Local1)
256 M201 (Arg1, VB03, Local1)
257 M331 (Arg1, Arg2, Arg3)
258 If (Arg6)
259 {
260 M201 (Arg1, VB03, "Fall into sleep")
261 If (SLM0)
262 {
263 Divide (Arg1, 0x05, Local1)
264 Local2 = 0x64
265 Switch (Local1)
266 {
267 Case (0x00)
268 {
269 Local2 = I100 /* \I100 */
270 }
271 Case (0x01)
272 {
273 Local2 = I101 /* \I101 */
274 }
275 Case (0x02)
276 {
277 Local2 = I102 /* \I102 */
278 }
279 Case (0x03)
280 {
281 Local2 = I103 /* \I103 */
282 }
283 Case (0x04)
284 {
285 Local2 = I104 /* \I104 */
286 }
287 Case (0x05)
288 {
289 Local2 = I105 /* \I105 */
290 }
291 Case (0x06)
292 {
293 Local2 = I106 /* \I106 */
294 }
295 Case (0x07)
296 {
297 Local2 = I107 /* \I107 */
298 }
299 Case (0x08)
300 {
301 Local2 = I108 /* \I108 */
302 }
303
304 }
305
306 M206 (Arg1, Local2)
307 }
308 Else
309 {
310 M206 (Arg1, SL01)
311 }
312 }
313 }
314
315 Return (0x00)
316 }
317
318 /*
319 * Release mutex
320 *
321 * arg0 - ID of current thread
322 * arg1 - Index of thread
323 * arg2 - Level of mutex
324 * arg3 - Index of mutex
325 * arg4 - opcode of exception to be generated or zero
326 * arg5 - if fall into sleep
327 */
328 Method (M311, 6, Serialized)
329 {
330 Local0 = M21E ("Release mutex, ", Arg2, Arg3)
331 M201 (Arg1, VB03, Local0)
332 /* Increment statistics of Release */
333
334 If (VB04)
335 {
336 M212 (RefOf (P106), Arg1)
337 }
338
339 /*
340 * Check up and reset flag (fl00) corresponding to this Mutex
341 * (check that it was not changed by other threads while this
342 * one was sleeping).
343 */
344 If (!Arg4)
345 {
346 M332 (Arg1, Arg2, Arg3)
347 }
348
349 Switch (Arg2)
350 {
351 Case (0x00)
352 {
353 MA10 (Arg3)
354 }
355 Case (0x01)
356 {
357 MA11 (Arg3)
358 }
359 Case (0x02)
360 {
361 MA12 (Arg3)
362 }
363 Case (0x03)
364 {
365 MA13 (Arg3)
366 }
367 Case (0x04)
368 {
369 MA14 (Arg3)
370 }
371 Case (0x05)
372 {
373 MA15 (Arg3)
374 }
375 Case (0x06)
376 {
377 MA16 (Arg3)
378 }
379 Case (0x07)
380 {
381 MA17 (Arg3)
382 }
383 Case (0x08)
384 {
385 MA18 (Arg3)
386 }
387 Case (0x09)
388 {
389 MA19 (Arg3)
390 }
391 Case (0x0A)
392 {
393 MA1A (Arg3)
394 }
395 Case (0x0B)
396 {
397 MA1B (Arg3)
398 }
399 Case (0x0C)
400 {
401 MA1C (Arg3)
402 }
403 Case (0x0D)
404 {
405 MA1D (Arg3)
406 }
407 Case (0x0E)
408 {
409 MA1E (Arg3)
410 }
411 Case (0x0F)
412 {
413 MA1F (Arg3)
414 }
415
416 }
417
418 If (Arg5)
419 {
420 M206 (Arg1, SL01)
421 }
422 }
423
424 /*
425 * Reset all counters (cnt0) and flags (fl00)
426 * corresponding to all Mutexes.
427 */
428 Method (M330, 0, Serialized)
429 {
430 Name (LPN0, 0x00)
431 Name (LPC0, 0x00)
432 Name (LPN1, 0x00)
433 Name (LPC1, 0x00)
434 LPN0 = MAX0 /* \MAX0 */
435 LPC0 = 0x00
436 While (LPN0)
437 {
438 LPN1 = MAX1 /* \MAX1 */
439 LPC1 = 0x00
440 While (LPN1)
441 {
442 DerefOf (CNT0 [LPC0]) [LPC1] = 0x00
443 DerefOf (FL00 [LPC0]) [LPC1] = 0x00
444 LPN1--
445 LPC1++
446 }
447
448 LPN0--
449 LPC0++
450 }
451 }
452
453 /*
454 * For Acquire
455 *
456 * Increment counter (cnt0) and set up flag (fl00)
457 * corresponding to the mutex of arg1-Level and
458 * arg2-Index. Report error in case the flag is non-zero.
459 *
460 * arg0 - Index of thread
461 * arg1 - Level of mutex
462 * arg2 - Index of mutex
463 */
464 Method (M331, 3, NotSerialized)
465 {
466 /* Local1 - the value of flag (index of thread owning the mutex) */
467
468 Local0 = DerefOf (FL00 [Arg1])
469 Local1 = DerefOf (Local0 [Arg2])
470 If (Local1)
471 {
472 If ((Local1 == Arg0))
473 {
474 Local7 = M21E ("Mutex ", Arg1, Arg2)
475 Concatenate (Local7, " is already owned by thr ", Local7)
476 Concatenate (Local7, Arg0, Local7)
477 WRN0 (Arg0, WN00, Local7)
478 }
479 Else
480 {
481 SE00 (Arg0, ER01, "Error er01")
482 }
483 }
484
485 /* Set up flag */
486
487 DerefOf (FL00 [Arg1]) [Arg2] = Arg0
488 /* Increment counter cnt0 (owning by all threads) */
489
490 Local0 = DerefOf (CNT0 [Arg1])
491 Local1 = DerefOf (Local0 [Arg2])
492 Local1++
493 DerefOf (CNT0 [Arg1]) [Arg2] = Local1
494 /* Increment counter fl01 (owning by one thread) */
495
496 Local0 = DerefOf (FL01 [Arg1])
497 Local1 = DerefOf (Local0 [Arg2])
498 Local1++
499 DerefOf (FL01 [Arg1]) [Arg2] = Local1
500 }
501
502 /*
503 * For Release
504 *
505 * Check up and reset flag (fl00) corresponding to this Mutex
506 * (check that it was not changed by other threads while this
507 * one was sleeping).
508 *
509 * arg0 - Index of thread
510 * arg1 - Level of mutex
511 * arg2 - Index of mutex
512 */
513 Method (M332, 3, NotSerialized)
514 {
515 /* Local1 - the value of flag (index of thread owning the mutex) */
516
517 Local0 = DerefOf (FL00 [Arg1])
518 Local1 = DerefOf (Local0 [Arg2])
519 If ((Local1 != Arg0))
520 {
521 SE00 (Arg0, ER02, "Error er02")
522 }
523 Else
524 {
525 /* Reset flag */
526 /* Local1 - counter of owning the mutex by the same thread */
527 Local0 = DerefOf (FL01 [Arg1])
528 Local1 = DerefOf (Local0 [Arg2])
529 If ((Local1 == 0x00))
530 {
531 SE00 (Arg0, ER08, "Error er08")
532 }
533 Else
534 {
535 Local1--
536 If ((Local1 == 0x00))
537 {
538 /*
539 * May be greater than one when owning mutex by the
540 * same thread several times (allowed for ACPI mutex).
541 */
542 DerefOf (FL00 [Arg1]) [Arg2] = 0x00
543 }
544
545 DerefOf (FL01 [Arg1]) [Arg2] = Local1
546 }
547 }
548 }
549
550 /*
551 * Check up the value of counter corresponding to this Mutex
552 *
553 * arg0 - Level of mutex
554 * arg1 - Index of mutex
555 * arg2 - expected value of counter
556 */
557 Method (M333, 3, NotSerialized)
558 {
559 Local0 = DerefOf (CNT0 [Arg0])
560 Local1 = DerefOf (Local0 [Arg1])
561 If ((Local1 != Arg2))
562 {
563 ERR ("m333", Z149, __LINE__, 0x00, 0x00, Local1, Arg2)
564 Debug = Arg0
565 Debug = Arg1
566 }
567 }
568
569 /*
570 * Specify the per-thread set of mutexes to deal with in operation
571 *
572 * arg0 - number of threads (threads actually in work)
573 * arg1 - opcode of initialization
574 * arg2 - Level of mutex (initial)
575 * arg3 - Number of levels of mutexes
576 * arg4 - Index of mutex (inside the level)
577 * arg5 - Number of mutexes of the same level
578 */
579 Method (M334, 6, Serialized)
580 {
581 Name (LPN0, 0x00)
582 Name (LPC0, 0x00)
583 LPN0 = Arg0
584 LPC0 = 0x00
585 While (LPN0)
586 {
587 /* For not a Control thread only */
588
589 If ((LPC0 != 0x00))
590 {
591 Switch (Arg1)
592 {
593 Case (0x01)
594 {
595 /* c301 */
596 /*
597 * One mutex of Index equal to
598 * ((Index of current thread) - 1)
599 */
600 P200 [LPC0] = Arg2
601 P201 [LPC0] = Arg3
602 Local0 = (LPC0 - 0x01)
603 P202 [LPC0] = Local0
604 P203 [LPC0] = 0x01
605 }
606 /* c300 */
607
608 Default
609 {
610 P200 [LPC0] = Arg2
611 P201 [LPC0] = Arg3
612 P202 [LPC0] = Arg4
613 P203 [LPC0] = Arg5
614 }
615
616 }
617 /* Switch() */
618 }
619
620 /* if() */
621
622 LPN0--
623 LPC0++
624 }
625 }
626
627 /*
628 * Control thread initiates workers to Acquire
629 * specified set of mutexes - on each specified
630 * level - one mutex of Index which is equal to
631 * ((Index of thread) - 1).
632 *
633 * When all workers complete that operation checks up
634 * the state of execution of operation provided by
635 * workers.
636 *
637 * arg0 - number of threads (total)
638 * arg1 - number of threads (threads actually in work)
639 *
640 * ====== as for m334:
641 * arg2 - Level of mutex (initial)
642 * arg3 - Number of levels of mutexes
643 *
644 * arg4 - expected value of counter
645 * arg5 - exceptional conditions flags (buffer/Integer)
646 */
647 Method (M337, 6, Serialized)
648 {
649 Name (LPN0, 0x00)
650 Name (LPC0, 0x00)
651 /* Acquire specified set of mutexes */
652 /* Set up per-thread set of mutexes */
653 M334 (Arg1, C301, Arg2, Arg3, 0x00, 0x00)
654 /* Init the exceptional conditions flags */
655
656 M215 (Arg0) /* Reset TimeOutValue and exceptional condition flags */
657 M20F (Arg1, Arg5, 0x00)
658 /* c106 for all first arg1 threads */
659
660 M210 (BS00, Arg0, C106, 0x00, Arg1, 0x01, C102) /* cmd: Acquire specified set of mutexes */
661 M114 (Arg0) /* run */
662 /* Wait for all Worker threads */
663
664 M103 (Arg0)
665 /* Check up the values of counters of all Mutexes */
666
667 LPN0 = Arg3
668 LPC0 = Arg2
669 While (LPN0)
670 {
671 M333 (LPC0, 0x00, Arg4)
672 LPN0--
673 LPC0++
674 }
675 }
676
677 /*
678 * Control thread initiates workers to Release
679 * specified set of mutexes - on each specified
680 * level - one mutex of Index which is equal to
681 * ((Index of thread) - 1).
682 *
683 * Control thread initiates workers to Release
684 * specified set of mutexes.
685 *
686 * arg0 - number of threads (total)
687 * arg1 - number of threads (threads actually in work)
688 *
689 * ====== as for m334:
690 * arg2 - Level of mutex (initial)
691 * arg3 - Number of levels of mutexes
692 */
693 Method (M338, 4, NotSerialized)
694 {
695 /* Set up per-thread set of mutexes */
696
697 M334 (Arg1, C301, Arg2, Arg3, 0x00, 0x00)
698 /* c107 for all first arg1 threads */
699
700 M210 (BS00, Arg0, C107, 0x00, Arg1, 0x01, C102) /* cmd: Release specified set of mutexes */
701 M114 (Arg0) /* run */
702 /* Wait for all Worker threads */
703
704 M103 (Arg0)
705 }
706
707 /*
708 * Control thread checks that the specified set of worker threads
709 * hang on the specified operations or completed the operations.
710 *
711 * See m10e for args:
712 * arg0 - number of threads
713 * arg1 - buffer
714 */
715 Method (M33D, 2, NotSerialized)
716 {
717 Local0 = M10F (Arg0, Arg1)
718 If ((Local0 & 0x01))
719 {
720 ERR ("m33d", Z149, __LINE__, 0x00, 0x00, Local0, 0x00)
721 }
722
723 If ((Local0 & 0x02))
724 {
725 ERR ("m33d", Z149, __LINE__, 0x00, 0x00, Local0, 0x00)
726 }
727 }
728
729 /*
730 * Run command for the specified set of workers
731 *
732 * arg0 - number of threads
733 * arg1 - specificator of elements (see m20a)
734 * arg2 - command
735 */
736 Method (M33E, 3, NotSerialized)
737 {
738 M20A (BS00, Arg0, Arg2, Arg1) /* cmd */
739 M114 (Arg0)
740 /* Wait for Worker threads */
741
742 M103 (Arg0)
743 }
744
745 /*
746 * Control thread initiates commands for workers to be fulfilled.
747 * After commands execution checks the statuses of all threads.
748 *
749 * It should be one of the following:
750 * - thread completed the specified command
751 * - thread hangs (on the specified command)
752 * - all other idle threads completed the 'idle-command'
753 * (for all those threads not enumerated in either 'Expected
754 * completion statuses' or 'Expected hang statuses' lists).
755 *
756 * Note: because of the restricted number of ACPI arguments available,
757 * the input data are combined.
758 *
759 * arg0 - numbers of threads (buffer/Integer).
760 * Integer:
761 * number of threads both total and 'actually in work'
762 * Buffer (elements of buffer):
763 * 0-th element - number of threads (total)
764 * 1-th element - number of threads (threads actually in work, not extra idle ones)
765 *
766 * arg1 - Commands (buffer/Integer).
767 *
768 * buffer/Integer, per-thread commands to be fulfilled
769 * Integer:
770 * 0 - undefined
771 * non-zero - the same command for all worker threads
772 * Buffer (elements of buffer):
773 * 0 - undefined
774 * non-zero - command for the relevant worker thread
775 *
776 * arg2 - Exceptional conditions flags (buffer/Integer)
777 *
778 * buffer/Integer, per-thread flags of exceptional conditions
779 * Integer:
780 * - non-zero means that we generate the same
781 * exceptional condition for all worker threads
782 * Buffer (elements of buffer):
783 * 0 - exception is not expected
784 * non-zero - means that we generate exceptional condition
785 * for the relevant thread
786 *
787 * The particular value (X0) of the exceptional condition flag
788 * corresponding to the particular thread means the following:
789 *
790 * 0: do nothing
791 * non-zero:
792 *
793 * 1) before to run operation:
794 *
795 * check absence of any exception occurred on this thread
796 *
797 * 2) after the operation is completed depending on X0:
798 *
799 * EX0E (particular undefined opcode of exception):
800 *
801 * check that no any exception occurred on this thread
802 *
803 * otherwise:
804 *
805 * check that exception with opcode equal to X0
806 * has occurred on this thread
807 *
808 * arg3 - Levels of mutexes (buffer/Integer).
809 *
810 * buffer/Integer, per-thread levels of mutexes
811 * Integer:
812 * - the same level of mutex for all worker threads
813 * (number of levels is 1)
814 * Buffer (elements of buffer):
815 * Pairs:
816 * - start level of mutex for the relevant thread
817 * - number of levels
818 *
819 * arg4 - Indexes of mutexes (buffer/Integer).
820 *
821 * buffer/Integer, per-thread indexes of mutexes
822 * Integer:
823 * - the same index of mutex for all worker threads
824 * (number of mutexes of the same level is 1)
825 * Buffer (elements of buffer):
826 * Pairs:
827 * - start index of mutex for the relevant thread
828 * - number of mutexes of the same level
829 *
830 * arg5 - Expected completion statuses (the same semantics as Commands) (buffer/Integer).
831 *
832 * buffer/Integer, per-thread commands to check for completion
833 * Integer:
834 * 0 - do nothing
835 * non-zero - the same command for all worker threads
836 * Buffer (elements of buffer):
837 * 0 - do nothing
838 * non-zero - command for the relevant worker thread
839 *
840 * arg6 - Expected hang statuses (the same semantics as Commands) (buffer/Integer).
841 *
842 * buffer/Integer, per-thread commands to check for hang
843 * Integer:
844 * 0 - do nothing
845 * non-zero - the same command for all worker threads
846 * Buffer (elements of buffer):
847 * 0 - do nothing
848 * non-zero - command for the relevant worker thread
849 *
850 * Note: non-zero 0-th element of the buffer means the
851 * number of hanging threads expected to wake up
852 * after some command of arg1 will be executed.
853 */
854 Method (M33F, 7, Serialized)
855 {
856 Name (NTH0, 0x00) /* total */
857 Name (NTH1, 0x00) /* actually in work */
858 Name (HAS1, 0x00) /* has non-zero exception expectations */
859 /* Check params */
860
861 Local0 = M344 (Arg5, Arg6)
862 If (Local0)
863 {
864 ERR ("m33f: incorrect parameters", Z149, __LINE__, 0x00, 0x00, Arg5, Arg6)
865 Debug = Local0
866 Return (Zero)
867 }
868
869 /* Parse number of threads */
870
871 If ((ObjectType (Arg0) == C009))
872 {
873 NTH0 = Arg0
874 NTH1 = Arg0
875 }
876 Else
877 {
878 NTH0 = DerefOf (Arg0 [0x00])
879 NTH1 = DerefOf (Arg0 [0x01])
880 }
881
882 /* 1) Command execution */
883 /*
884 * Prepare buffers of per-thread commands and arguments
885 *
886 * Resulting data: bs00, p200, p201, p202, p203, p204
887 *
888 * Note: not specified elements of buffers are not touched.
889 */
890 HAS1 = M340 (NTH1, Arg1, Arg2, Arg3, Arg4)
891 /* Allow workers to execute their commands */
892
893 M114 (NTH0)
894 /* 2) Check status of execution of commands */
895 /* Calculate the per-thread expectations of completion statuses */
896 Local0 = M342 (NTH0, NTH1, Arg5)
897 /* Calculate the per-thread expectations of hang statuses */
898
899 Local1 = M342 (NTH0, NTH1, Arg6)
900 /* Calculate the idle-threads mapping buffer */
901
902 Local2 = M343 (NTH0, NTH1, Local0, Local1)
903 /*
904 * So, each thread is represented in one and only one of sets:
905 *
906 * Local0 - expectations of completion
907 * Local1 - expectations of hang
908 * Local2 - idle
909 */
910 /* Wait for all Worker threads and check their statuses */
911 M110 (NTH0, Local0, Local1, Local2)
912 /* Reset exception expectation */
913
914 M336 (NTH0, HAS1)
915 }
916
917 /*
918 * Prepare buffers of per-thread commands and arguments
919 *
920 * Resulting data: bs00, p200, p201, p202, p203
921 *
922 * Note: don't touch not specified elements of buffer.
923 *
924 * arg0 - number of threads (threads actually in work)
925 * arg1 - Commands (see m33f)
926 * arg2 - Exceptional conditions flags (see m33f)
927 * arg3 - Levels of mutexes (see m33f)
928 * arg4 - Indexes of mutexes (see m33f)
929 */
930 Method (M340, 5, Serialized)
931 {
932 Name (HAS0, 0x00)
933 Name (HAS1, 0x00) /* has non-zero exception expectations */
934 Name (LPN0, 0x00)
935 Name (LPC0, 0x00)
936 Name (SLCT, 0x00)
937 Name (CMD0, 0x00)
938 Name (B000, Buffer (Arg0){})
939 Name (B200, Buffer (Arg0){})
940 Name (B201, Buffer (Arg0){})
941 Name (B202, Buffer (Arg0){})
942 Name (B203, Buffer (Arg0){})
943 Local0 = ObjectType (Arg1)
944 If ((Local0 == C009))
945 {
946 /* Integer */
947
948 CMD0 = Arg1
949 If (!CMD0)
950 {
951 Return (Zero)
952 }
953 }
954 Else
955 {
956 /* Buffer/Package */
957
958 SLCT = 0x01
959 }
960
961 LPN0 = Arg0
962 LPC0 = 0x00
963 While (LPN0)
964 {
965 /* For not a Control thread only */
966
967 If ((LPC0 != 0x00))
968 {
969 If (SLCT)
970 {
971 CMD0 = DerefOf (Arg1 [LPC0])
972 }
973
974 If (CMD0)
975 {
976 HAS0 = 0x01
977 B000 [LPC0] = CMD0 /* \M340.CMD0 */
978 /* Prepare arguments of command */
979
980 Local0 = M341 (CMD0, LPC0, Arg3, Arg4)
981 If ((ObjectType (Local0) == C00C))
982 {
983 Local1 = DerefOf (Local0 [0x00])
984 B200 [LPC0] = Local1
985 Local1 = DerefOf (Local0 [0x01])
986 B201 [LPC0] = Local1
987 Local1 = DerefOf (Local0 [0x02])
988 B202 [LPC0] = Local1
989 Local1 = DerefOf (Local0 [0x03])
990 B203 [LPC0] = Local1
991 }
992 }
993 }
994
995 LPN0--
996 LPC0++
997 }
998
999 /* Prepare the exceptional conditions flags buffer */
1000
1001 Local1 = M20E (Arg0, Arg2)
1002 /*
1003 * Prepare all the commands and arguments and then re-write
1004 * them into the target buffers looks there useful for debugging.
1005 */
1006 If (HAS0)
1007 {
1008 LPN0 = Arg0
1009 LPC0 = 0x00
1010 While (LPN0)
1011 {
1012 CMD0 = DerefOf (B000 [LPC0])
1013 If (CMD0)
1014 {
1015 BS00 [LPC0] = CMD0 /* \M340.CMD0 */
1016 Local0 = DerefOf (B200 [LPC0])
1017 P200 [LPC0] = Local0
1018 Local0 = DerefOf (B201 [LPC0])
1019 P201 [LPC0] = Local0
1020 Local0 = DerefOf (B202 [LPC0])
1021 P202 [LPC0] = Local0
1022 Local0 = DerefOf (B203 [LPC0])
1023 P203 [LPC0] = Local0
1024 Local0 = DerefOf (Local1 [LPC0])
1025 If (Local0)
1026 {
1027 HAS1 = 0x01
1028 }
1029
1030 P204 [LPC0] = Local0
1031 P205 [LPC0] = TOVF /* \TOVF */
1032 }
1033
1034 LPN0--
1035 LPC0++
1036 }
1037 }
1038
1039 Return (HAS1) /* \M340.HAS1 */
1040 }
1041
1042 /*
1043 * Prepare arguments of command
1044 *
1045 * arg0 - command
1046 * arg1 - index of thread
1047 * arg2 - Levels of mutexes (see m33f)
1048 * arg3 - Indexes of mutexes (see m33f)
1049 *
1050 * Return (no free ArgX to pass references to target Packages there,
1051 * so using Return):
1052 * - Package with elements to be filled
1053 * into p200, p201, p202, p203.
1054 * - Integer if no arguments.
1055 */
1056 Method (M341, 4, Serialized)
1057 {
1058 Name (HAS0, 0x00)
1059 Name (P000, Package (0x04)
1060 {
1061 0x00,
1062 0x00,
1063 0x00,
1064 0x00
1065 })
1066 Name (I000, 0x00)
1067 Name (I001, 0x00)
1068 Name (I002, 0x00)
1069 Name (I003, 0x00)
1070 Switch (Arg0)
1071 {
1072 Case (Package (0x03)
1073 {
1074 0xF6,
1075 0xF7,
1076 0xF3
1077 }
1078
1079 )
1080 {
1081 /* 0xf6, c106 - Acquire specified set of mutexes */
1082 /* 0xf7, c107 - Release specified set of mutexes */
1083 /* 0xf3, c103 - Acquire/Sleep/Release */
1084 /*
1085 * To calculate:
1086 *
1087 * i000 - starting level of mutex
1088 * i001 - number of levels
1089 * i002 - starting index of mutex (of the same level)
1090 * i003 - number of mutexes (of the same level)
1091 */
1092 /* Levels */
1093 Local0 = ObjectType (Arg2)
1094 If ((Local0 == C009))
1095 {
1096 /* Integer */
1097
1098 I000 = Arg2
1099 I001 = 0x01
1100 }
1101 Else
1102 {
1103 /* Buffer/Package */
1104
1105 Local0 = (Arg1 * 0x02)
1106 I000 = DerefOf (Arg2 [Local0])
1107 Local0++
1108 I001 = DerefOf (Arg2 [Local0])
1109 }
1110
1111 /* Indexes */
1112
1113 Local0 = ObjectType (Arg3)
1114 If ((Local0 == C009))
1115 {
1116 /* Integer */
1117
1118 I002 = Arg3
1119 I003 = 0x01
1120 }
1121 Else
1122 {
1123 /* Buffer/Package */
1124
1125 Local0 = (Arg1 * 0x02)
1126 I002 = DerefOf (Arg3 [Local0])
1127 Local0++
1128 I003 = DerefOf (Arg3 [Local0])
1129 }
1130
1131 HAS0 = 0x01
1132 }
1133 Default
1134 {
1135 ERR ("m341: unexpected command:", Z149, __LINE__, 0x00, 0x00, 0x00, Arg0)
1136 }
1137
1138 }
1139
1140 If (HAS0)
1141 {
1142 P000 [0x00] = I000 /* \M341.I000 */
1143 P000 [0x01] = I001 /* \M341.I001 */
1144 P000 [0x02] = I002 /* \M341.I002 */
1145 P000 [0x03] = I003 /* \M341.I003 */
1146 Return (P000) /* \M341.P000 */
1147 }
1148
1149 Return (0x00)
1150 }
1151
1152 /*
1153 * Prepare the per-thread status expectations mapping buffer
1154 *
1155 * arg0 - number of threads (total)
1156 * arg1 - number of threads (threads actually in work)
1157 * arg2 - Expected completion/hang statuses (see m33f)
1158 *
1159 * Return:
1160 *
1161 * Buffer (elements of buffer):
1162 * 0 - nothing to do for the relevant thread
1163 * non-zero - element of buffer means the last command
1164 * specified for the relevant thread.
1165 */
1166 Method (M342, 3, Serialized)
1167 {
1168 Name (LPN0, 0x00)
1169 Name (LPC0, 0x00)
1170 Name (SLCT, 0x00)
1171 Name (CMD0, 0x00)
1172 Name (B000, Buffer (Arg0){})
1173 Local0 = ObjectType (Arg2)
1174 If ((Local0 == C009))
1175 {
1176 /* Integer */
1177
1178 CMD0 = Arg2
1179 If (!CMD0)
1180 {
1181 Return (B000) /* \M342.B000 */
1182 }
1183 }
1184 Else
1185 {
1186 /* Buffer/Package */
1187
1188 SLCT = 0x01
1189 }
1190
1191 LPN0 = Arg1
1192 LPC0 = 0x00
1193 While (LPN0)
1194 {
1195 If (SLCT)
1196 {
1197 CMD0 = DerefOf (Arg2 [LPC0])
1198 }
1199
1200 If (CMD0)
1201 {
1202 B000 [LPC0] = CMD0 /* \M342.CMD0 */
1203 }
1204
1205 LPN0--
1206 LPC0++
1207 }
1208
1209 Return (B000) /* \M342.B000 */
1210 }
1211
1212 /*
1213 * Prepare the idle-threads mapping buffer
1214 *
1215 * arg0 - number of threads (total)
1216 * arg1 - number of threads (threads actually in work, not extra idle ones)
1217 * arg2 - Buffer, expected completion statuses (see m33f)
1218 * arg3 - Buffer, Expected hang statuses (see m33f)
1219 *
1220 * Return:
1221 *
1222 * Buffer (elements of buffer):
1223 * 0 - the relevant thread is non-idle
1224 * non-zero - the relevant thread is idle
1225 */
1226 Method (M343, 4, Serialized)
1227 {
1228 Name (ERR0, 0x00)
1229 Name (IDLE, 0x00)
1230 Name (LPN0, 0x00)
1231 Name (LPC0, 0x00)
1232 Name (B000, Buffer (Arg0){})
1233 LPN0 = Arg0
1234 LPC0 = 0x00
1235 While (LPN0)
1236 {
1237 IDLE = 0x00
1238 If ((LPC0 >= Arg1))
1239 {
1240 IDLE = 0x01
1241 }
1242 Else
1243 {
1244 Local0 = DerefOf (Arg2 [LPC0])
1245 Local1 = DerefOf (Arg3 [LPC0])
1246 If ((Local0 && Local1))
1247 {
1248 /* Expects both completion and hang simultaneously */
1249
1250 ERR0 = 0x01
1251 }
1252 ElseIf ((!Local0 && !Local1))
1253 {
1254 IDLE = 0x01
1255 }
1256 }
1257
1258 B000 [LPC0] = IDLE /* \M343.IDLE */
1259 LPN0--
1260 LPC0++
1261 }
1262
1263 If (ERR0)
1264 {
1265 ERR ("m333", Z149, __LINE__, 0x00, 0x00, 0x00, 0x00)
1266 }
1267
1268 Return (B000) /* \M343.B000 */
1269 }
1270
1271 /*
1272 * Check pair of parameters
1273 *
1274 * arg0 - Expected completion statuses (see m33f).
1275 * arg1 - Expected hang statuses (see m33f).
1276 */
1277 Method (M344, 2, Serialized)
1278 {
1279 Name (INT0, 0x00)
1280 Name (INT1, 0x00)
1281 Name (ALL0, 0x00)
1282 Name (ALL1, 0x00)
1283 If ((ObjectType (Arg0) == C009))
1284 {
1285 INT0 = 0x01
1286 If (Arg0)
1287 {
1288 ALL0 = 0x01
1289 }
1290 }
1291
1292 If ((ObjectType (Arg1) == C009))
1293 {
1294 INT1 = 0x01
1295 If (Arg1)
1296 {
1297 ALL1 = 0x01
1298 }
1299 }
1300
1301 If ((ALL0 || ALL1))
1302 {
1303 If ((INT0 && INT0))
1304 {
1305 If ((ALL0 && ALL1))
1306 {
1307 Return (0x01)
1308 }
1309 }
1310 Else
1311 {
1312 Return (0x02)
1313 }
1314 }
1315
1316 Return (0x00)
1317 }
1318
1319 /*
1320 * Reset exception expectation
1321 *
1322 * arg0 - number of threads (total)
1323 * arg1 - non-zero -- has non-zero exception expectations
1324 */
1325 Method (M336, 2, NotSerialized)
1326 {
1327 /* Add statistics of exceptions (total) */
1328
1329 EX10 += EXC0 /* \EXC0 */
1330 If (Arg1)
1331 {
1332 If (!EXC0)
1333 {
1334 /* Expected exceptions but have none */
1335
1336 ERR ("m333", Z149, __LINE__, 0x00, 0x00, EXC0, 0x00)
1337 }
1338 }
1339 ElseIf (EXC0)
1340 {
1341 /* Unexpected exceptions */
1342
1343 ERR ("m333", Z149, __LINE__, 0x00, 0x00, EXC0, 0x00)
1344 }
1345
1346 /*Reset EXC0 (the current number of exceptions handled) */
1347
1348 CH0A ()
1349 M215 (Arg0) /* Reset TimeOutValue and exceptional condition flags */
1350 }
1351
1352 /* Init fl01 */
1353
1354 Method (M339, 0, Serialized)
1355 {
1356 Name (LPN0, 0x00)
1357 Name (LPC0, 0x00)
1358 Name (LPN1, 0x00)
1359 Name (LPC1, 0x00)
1360 LPN0 = MAX0 /* \MAX0 */
1361 LPC0 = 0x00
1362 While (LPN0)
1363 {
1364 LPN1 = MAX1 /* \MAX1 */
1365 LPC1 = 0x00
1366 While (LPN1)
1367 {
1368 DerefOf (FL01 [LPC0]) [LPC1] = 0x00
1369 LPN1--
1370 LPC1++
1371 }
1372
1373 LPN0--
1374 LPC0++
1375 }
1376 }