• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /barrelfish-2018-10-04/lib/acpica/tests/aslts/src/runtime/collections/functional/synchronization/
1/*
2 * Some or all of this work - Copyright (c) 2006 - 2016, 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/*
30 * Check for exceptions on mutexes
31 */
32
33Name(z150, 150)
34
35/*
36 * Run checking that all mutexes are actually Released.
37 * To be used while debugging the tests mainly.
38 */
39Name(FL03, 0)
40
41/* Counter for m08e */
42Name(cn00, 0)
43
44
45/*
46 * These declarations are used for to check the Acquire
47 * and Release operations in a global level AML code.
48 */
49Name(i101, 0) // non-zero means that this test was run
50
51/*
52 * Valid sequence of requests, no exceptions expected.
53 *
54 * Acquire mutexes of monotone increasing level (Global lock
55 * on level 0 too) for all available levels from 0 up to 15,
56 * then Release them all in the inverse order.
57 */
58Method(m301,, Serialized)
59{
60    Mutex(MT00, 0)
61    Mutex(MT10, 1)
62    Mutex(MT20, 2)
63    Mutex(MT30, 3)
64    Mutex(MT40, 4)
65    Mutex(MT50, 5)
66    Mutex(MT60, 6)
67    Mutex(MT70, 7)
68    Mutex(MT80, 8)
69    Mutex(MT90, 9)
70    Mutex(MTa0, 10)
71    Mutex(MTb0, 11)
72    Mutex(MTc0, 12)
73    Mutex(MTd0, 13)
74    Mutex(MTe0, 14)
75    Mutex(MTf0, 15)
76
77    Name(ts, "m301")
78
79    CH03(ts, z150, 0x000, 0, 0)
80
81    Store(Acquire(MT00, 0xffff), Local0)
82    if (Local0) {
83        err(ts, z150, 1, 0, 0, 0, Local0)
84    } else {
85    Store(Acquire(\_GL, 0xffff), Local0) /* GL */
86    if (Local0) {
87        err(ts, z150, 3, 0, 0, 0, Local0)
88    } else {
89        Store(Acquire(MT10, 0xffff), Local0)
90        if (Local0) {
91            err(ts, z150, 2, 0, 0, 0, Local0)
92        } else {
93            Store(Acquire(MT20, 0xffff), Local0)
94            if (Local0) {
95                err(ts, z150, 3, 0, 0, 0, Local0)
96            } else {
97                Store(Acquire(MT30, 0xffff), Local0)
98                if (Local0) {
99                    err(ts, z150, 4, 0, 0, 0, Local0)
100                } else {
101                    Store(Acquire(MT40, 0xffff), Local0)
102                    if (Local0) {
103                        err(ts, z150, 5, 0, 0, 0, Local0)
104                    } else {
105                        Store(Acquire(MT50, 0xffff), Local0)
106                        if (Local0) {
107                            err(ts, z150, 6, 0, 0, 0, Local0)
108                        } else {
109                            Store(Acquire(MT60, 0xffff), Local0)
110                            if (Local0) {
111                                err(ts, z150, 7, 0, 0, 0, Local0)
112                            } else {
113                                Store(Acquire(MT70, 0xffff), Local0)
114                                if (Local0) {
115                                    err(ts, z150, 8, 0, 0, 0, Local0)
116                                } else {
117                                    Store(Acquire(MT80, 0xffff), Local0)
118                                    if (Local0) {
119                                        err(ts, z150, 9, 0, 0, 0, Local0)
120                                    } else {
121                                        Store(Acquire(MT90, 0xffff), Local0)
122                                        if (Local0) {
123                                            err(ts, z150, 0x00a, 0, 0, 0, Local0)
124                                        } else {
125                                            Store(Acquire(MTa0, 0xffff), Local0)
126                                            if (Local0) {
127                                                err(ts, z150, 0x00b, 0, 0, 0, Local0)
128                                            } else {
129                                                Store(Acquire(MTb0, 0xffff), Local0)
130                                                if (Local0) {
131                                                    err(ts, z150, 0x00c, 0, 0, 0, Local0)
132                                                } else {
133                                                    Store(Acquire(MTc0, 0xffff), Local0)
134                                                    if (Local0) {
135                                                        err(ts, z150, 0x00d, 0, 0, 0, Local0)
136                                                    } else {
137                                                        Store(Acquire(MTd0, 0xffff), Local0)
138                                                        if (Local0) {
139                                                            err(ts, z150, 0x00e, 0, 0, 0, Local0)
140                                                        } else {
141                                                            Store(Acquire(MTe0, 0xffff), Local0)
142                                                            if (Local0) {
143                                                                err(ts, z150, 0x00f, 0, 0, 0, Local0)
144                                                            } else {
145                                                                Store(Acquire(MTf0, 0xffff), Local0)
146                                                                if (Local0) {
147                                                                    err(ts, z150, 0x010, 0, 0, 0, Local0)
148                                                                } else {
149                                                                    Release(MTF0)
150                                                                    Release(MTE0)
151                                                                    Release(MTD0)
152                                                                    Release(MTC0)
153                                                                    Release(MTB0)
154                                                                    Release(MTA0)
155                                                                    Release(MT90)
156                                                                    Release(MT80)
157                                                                    Release(MT70)
158                                                                    Release(MT60)
159                                                                    Release(MT50)
160                                                                    Release(MT40)
161                                                                    Release(MT30)
162                                                                    Release(MT20)
163                                                                    Release(MT10)
164                                                                    Release(\_GL)
165                                                                    Release(MT00)
166                                                                }
167                                                            }
168                                                        }
169                                                    }
170                                                }
171                                            }
172                                        }
173                                    }
174                                }
175                            }
176                        }
177                    }
178                }
179            }
180        }
181    }
182    }
183
184    CH03(ts, z150, 0x011, 0, 0)
185}
186
187/*
188 * Valid sequence of requests, no exceptions expected.
189 *
190 * Acquire mutexes of monotone increasing level (Global lock on level 0 too)
191 * for all available levels from 0 up to 15, Acquire 2 mutexes of each level,
192 * then Release them all in the inverse order (keep the exactly inverse order
193 * for Releasing mutexes of the same level too).
194 *
195 * arg0 - if to force AE_LIMIT by exceeding the maximal number of created mutexes
196 */
197Method(m369, 1, Serialized)
198{
199    Name(ts, "m369")
200
201    CH03(ts, z150, 0x022, 0, 0)
202
203    Mutex(MT00, 0)
204    Mutex(MT10, 1)
205    Mutex(MT20, 2)
206    Mutex(MT30, 3)
207    Mutex(MT40, 4)
208    Mutex(MT50, 5)
209    Mutex(MT60, 6)
210    Mutex(MT70, 7)
211    Mutex(MT80, 8)
212    Mutex(MT90, 9)
213    Mutex(MTa0, 10)
214    Mutex(MTb0, 11)
215    Mutex(MTc0, 12)
216    Mutex(MTd0, 13)
217    Mutex(MTe0, 14)
218    Mutex(MTf0, 15)
219
220    Mutex(MT01, 0)
221    Mutex(MT11, 1)
222    Mutex(MT21, 2)
223    Mutex(MT31, 3)
224    Mutex(MT41, 4)
225    Mutex(MT51, 5)
226    Mutex(MT61, 6)
227    Mutex(MT71, 7)
228    Mutex(MT81, 8)
229    Mutex(MT91, 9)
230    Mutex(MTa1, 10)
231    Mutex(MTb1, 11)
232    Mutex(MTc1, 12)
233    Mutex(MTd1, 13)
234    Mutex(MTe1, 14)
235    if (arg0) {
236
237        // Should be enough to exceed the maximal available number of mutexes
238        Mutex(MTf1, 15)
239        Mutex(MTf2, 15)
240        Mutex(MTf3, 15)
241        Mutex(MTf4, 15)
242    }
243
244    Store(Acquire(MT00, 0xffff), Local0)
245    if (Local0) {
246        err(ts, z150, 1, 0, 0, 0, Local0)
247    } else {
248    Store(Acquire(MT01, 0xffff), Local0) /* the same level */
249    if (Local0) {
250        err(ts, z150, 2, 0, 0, 0, Local0)
251    } else {
252    Store(Acquire(\_GL, 0xffff), Local0) /* GL */
253    if (Local0) {
254        err(ts, z150, 3, 0, 0, 0, Local0)
255    } else {
256        Store(Acquire(MT10, 0xffff), Local0)
257        if (Local0) {
258            err(ts, z150, 4, 0, 0, 0, Local0)
259        } else {
260        Store(Acquire(MT11, 0xffff), Local0)
261        if (Local0) {
262            err(ts, z150, 5, 0, 0, 0, Local0)
263        } else {
264            Store(Acquire(MT20, 0xffff), Local0)
265            if (Local0) {
266                err(ts, z150, 6, 0, 0, 0, Local0)
267            } else {
268            Store(Acquire(MT21, 0xffff), Local0)
269            if (Local0) {
270                err(ts, z150, 7, 0, 0, 0, Local0)
271            } else {
272                Store(Acquire(MT30, 0xffff), Local0)
273                if (Local0) {
274                    err(ts, z150, 8, 0, 0, 0, Local0)
275                } else {
276                Store(Acquire(MT31, 0xffff), Local0)
277                if (Local0) {
278                    err(ts, z150, 9, 0, 0, 0, Local0)
279                } else {
280                    Store(Acquire(MT40, 0xffff), Local0)
281                    if (Local0) {
282                        err(ts, z150, 0x00a, 0, 0, 0, Local0)
283                    } else {
284                    Store(Acquire(MT41, 0xffff), Local0)
285                    if (Local0) {
286                        err(ts, z150, 0x00b, 0, 0, 0, Local0)
287                    } else {
288                        Store(Acquire(MT50, 0xffff), Local0)
289                        if (Local0) {
290                            err(ts, z150, 0x00c, 0, 0, 0, Local0)
291                        } else {
292                        Store(Acquire(MT51, 0xffff), Local0)
293                        if (Local0) {
294                            err(ts, z150, 0x00d, 0, 0, 0, Local0)
295                        } else {
296                            Store(Acquire(MT60, 0xffff), Local0)
297                            if (Local0) {
298                                err(ts, z150, 0x00e, 0, 0, 0, Local0)
299                            } else {
300                            Store(Acquire(MT61, 0xffff), Local0)
301                            if (Local0) {
302                                err(ts, z150, 0x00f, 0, 0, 0, Local0)
303                            } else {
304                                Store(Acquire(MT70, 0xffff), Local0)
305                                if (Local0) {
306                                    err(ts, z150, 0x010, 0, 0, 0, Local0)
307                                } else {
308                                Store(Acquire(MT71, 0xffff), Local0)
309                                if (Local0) {
310                                    err(ts, z150, 0x011, 0, 0, 0, Local0)
311                                } else {
312                                    Store(Acquire(MT80, 0xffff), Local0)
313                                    if (Local0) {
314                                        err(ts, z150, 0x012, 0, 0, 0, Local0)
315                                    } else {
316                                    Store(Acquire(MT81, 0xffff), Local0)
317                                    if (Local0) {
318                                        err(ts, z150, 0x013, 0, 0, 0, Local0)
319                                    } else {
320                                        Store(Acquire(MT90, 0xffff), Local0)
321                                        if (Local0) {
322                                            err(ts, z150, 0x014, 0, 0, 0, Local0)
323                                        } else {
324                                        Store(Acquire(MT91, 0xffff), Local0)
325                                        if (Local0) {
326                                            err(ts, z150, 0x015, 0, 0, 0, Local0)
327                                        } else {
328                                            Store(Acquire(MTa0, 0xffff), Local0)
329                                            if (Local0) {
330                                                err(ts, z150, 0x016, 0, 0, 0, Local0)
331                                            } else {
332                                            Store(Acquire(MTa1, 0xffff), Local0)
333                                            if (Local0) {
334                                                err(ts, z150, 0x017, 0, 0, 0, Local0)
335                                            } else {
336                                                Store(Acquire(MTb0, 0xffff), Local0)
337                                                if (Local0) {
338                                                    err(ts, z150, 0x018, 0, 0, 0, Local0)
339                                                } else {
340                                                Store(Acquire(MTb1, 0xffff), Local0)
341                                                if (Local0) {
342                                                    err(ts, z150, 0x019, 0, 0, 0, Local0)
343                                                } else {
344                                                    Store(Acquire(MTc0, 0xffff), Local0)
345                                                    if (Local0) {
346                                                        err(ts, z150, 0x01a, 0, 0, 0, Local0)
347                                                    } else {
348                                                    Store(Acquire(MTc1, 0xffff), Local0)
349                                                    if (Local0) {
350                                                        err(ts, z150, 0x01b, 0, 0, 0, Local0)
351                                                    } else {
352                                                        Store(Acquire(MTd0, 0xffff), Local0)
353                                                        if (Local0) {
354                                                            err(ts, z150, 0x01c, 0, 0, 0, Local0)
355                                                        } else {
356                                                        Store(Acquire(MTd1, 0xffff), Local0)
357                                                        if (Local0) {
358                                                            err(ts, z150, 0x01d, 0, 0, 0, Local0)
359                                                        } else {
360                                                            Store(Acquire(MTe0, 0xffff), Local0)
361                                                            if (Local0) {
362                                                                err(ts, z150, 0x01e, 0, 0, 0, Local0)
363                                                            } else {
364                                                            Store(Acquire(MTe1, 0xffff), Local0)
365                                                            if (Local0) {
366                                                                err(ts, z150, 0x01f, 0, 0, 0, Local0)
367                                                            } else {
368                                                                Store(Acquire(MTf0, 0xffff), Local0)
369                                                                if (Local0) {
370                                                                    err(ts, z150, 0x020, 0, 0, 0, Local0)
371                                                                } else {
372                                                                if (arg0) {
373                                                                    Store(Acquire(MTf1, 0xffff), Local0)
374                                                                } else {
375                                                                    Store(0, Local0)
376                                                                }
377                                                                if (Local0) {
378                                                                    err(ts, z150, 0x021, 0, 0, 0, Local0)
379                                                                } else {
380                                                                    if (arg0) {
381                                                                        Release(MTF1)
382                                                                    }
383                                                                    Release(MTF0)
384                                                                    Release(MTE1)
385                                                                    Release(MTE0)
386                                                                    Release(MTD1)
387                                                                    Release(MTD0)
388                                                                    Release(MTC1)
389                                                                    Release(MTC0)
390                                                                    Release(MTB1)
391                                                                    Release(MTB0)
392                                                                    Release(MTA1)
393                                                                    Release(MTA0)
394                                                                    Release(MT91)
395                                                                    Release(MT90)
396                                                                    Release(MT81)
397                                                                    Release(MT80)
398                                                                    Release(MT71)
399                                                                    Release(MT70)
400                                                                    Release(MT61)
401                                                                    Release(MT60)
402                                                                    Release(MT51)
403                                                                    Release(MT50)
404                                                                    Release(MT41)
405                                                                    Release(MT40)
406                                                                    Release(MT31)
407                                                                    Release(MT30)
408                                                                    Release(MT21)
409                                                                    Release(MT20)
410                                                                    Release(MT11)
411                                                                    Release(MT10)
412                                                                    Release(\_GL)
413                                                                    Release(MT01)
414                                                                    Release(MT00)
415                                                                }
416                                                                }
417                                                            }
418                                                            }
419                                                        }
420                                                        }
421                                                    }
422                                                    }
423                                                }
424                                                }
425                                            }
426                                            }
427                                        }
428                                        }
429                                    }
430                                    }
431                                }
432                                }
433                            }
434                            }
435                        }
436                        }
437                    }
438                    }
439                }
440                }
441            }
442            }
443        }
444        }
445    }
446    }
447    }
448
449    if (arg0) {
450        CH04(ts, 1, 18, z150, 0x122, 0, 0) // AE_LIMIT
451    } else {
452        CH03(ts, z150, 0x123, 0, 0)
453    }
454}
455
456/*
457 * Valid sequence of requests, no exceptions expected.
458 *
459 * Acquire mutexes of monotone increasing level (Global lock
460 * on level 0 too) for all available levels from 0 up to 15,
461 * then Release them all in the inverse order.
462 *
463 * Exactly m301 but additioanlly:
464 *    all Release opreations are located into separate method.
465 */
466Method(m36a,, Serialized)
467{
468    Mutex(MT00, 0)
469    Mutex(MT10, 1)
470    Mutex(MT20, 2)
471    Mutex(MT30, 3)
472    Mutex(MT40, 4)
473    Mutex(MT50, 5)
474    Mutex(MT60, 6)
475    Mutex(MT70, 7)
476    Mutex(MT80, 8)
477    Mutex(MT90, 9)
478    Mutex(MTa0, 10)
479    Mutex(MTb0, 11)
480    Mutex(MTc0, 12)
481    Mutex(MTd0, 13)
482    Mutex(MTe0, 14)
483    Mutex(MTf0, 15)
484
485    Name(ts, "m36a")
486
487    Method(m000)
488    {
489
490    Store(Acquire(MT00, 0xffff), Local0)
491    if (Local0) {
492        err(ts, z150, 1, 0, 0, 0, Local0)
493    } else {
494    Store(Acquire(\_GL, 0xffff), Local0)
495    if (Local0) {
496        err(ts, z150, 2, 0, 0, 0, Local0)
497    } else {
498        Store(Acquire(MT10, 0xffff), Local0)
499        if (Local0) {
500            err(ts, z150, 3, 0, 0, 0, Local0)
501        } else {
502            Store(Acquire(MT20, 0xffff), Local0)
503            if (Local0) {
504                err(ts, z150, 4, 0, 0, 0, Local0)
505            } else {
506                Store(Acquire(MT30, 0xffff), Local0)
507                if (Local0) {
508                    err(ts, z150, 5, 0, 0, 0, Local0)
509                } else {
510                    Store(Acquire(MT40, 0xffff), Local0)
511                    if (Local0) {
512                        err(ts, z150, 6, 0, 0, 0, Local0)
513                    } else {
514                        Store(Acquire(MT50, 0xffff), Local0)
515                        if (Local0) {
516                            err(ts, z150, 7, 0, 0, 0, Local0)
517                        } else {
518                            Store(Acquire(MT60, 0xffff), Local0)
519                            if (Local0) {
520                                err(ts, z150, 8, 0, 0, 0, Local0)
521                            } else {
522                                Store(Acquire(MT70, 0xffff), Local0)
523                                if (Local0) {
524                                    err(ts, z150, 9, 0, 0, 0, Local0)
525                                } else {
526                                    Store(Acquire(MT80, 0xffff), Local0)
527                                    if (Local0) {
528                                        err(ts, z150, 0x00a, 0, 0, 0, Local0)
529                                    } else {
530                                        Store(Acquire(MT90, 0xffff), Local0)
531                                        if (Local0) {
532                                            err(ts, z150, 0x00b, 0, 0, 0, Local0)
533                                        } else {
534                                            Store(Acquire(MTa0, 0xffff), Local0)
535                                            if (Local0) {
536                                                err(ts, z150, 0x00c, 0, 0, 0, Local0)
537                                            } else {
538                                                Store(Acquire(MTb0, 0xffff), Local0)
539                                                if (Local0) {
540                                                    err(ts, z150, 0x00d, 0, 0, 0, Local0)
541                                                } else {
542                                                    Store(Acquire(MTc0, 0xffff), Local0)
543                                                    if (Local0) {
544                                                        err(ts, z150, 0x00e, 0, 0, 0, Local0)
545                                                    } else {
546                                                        Store(Acquire(MTd0, 0xffff), Local0)
547                                                        if (Local0) {
548                                                            err(ts, z150, 0x00f, 0, 0, 0, Local0)
549                                                        } else {
550                                                            Store(Acquire(MTe0, 0xffff), Local0)
551                                                            if (Local0) {
552                                                                err(ts, z150, 0x010, 0, 0, 0, Local0)
553                                                            } else {
554                                                                Store(Acquire(MTf0, 0xffff), Local0)
555                                                                if (Local0) {
556                                                                    err(ts, z150, 0x011, 0, 0, 0, Local0)
557                                                                } else {
558                                                                    m001()
559                                                                }
560                                                            }
561                                                        }
562                                                    }
563                                                }
564                                            }
565                                        }
566                                    }
567                                }
568                            }
569                        }
570                    }
571                }
572            }
573        }
574    }
575    }
576    } /* m000 */
577
578    Method(m001)
579    {
580		Release(MTF0)
581		Release(MTE0)
582		Release(MTD0)
583		Release(MTC0)
584		Release(MTB0)
585		Release(MTA0)
586		Release(MT90)
587		Release(MT80)
588		Release(MT70)
589		Release(MT60)
590		Release(MT50)
591		Release(MT40)
592		Release(MT30)
593		Release(MT20)
594		Release(MT10)
595		Release(\_GL)
596		Release(MT00)
597    }
598
599    CH03(ts, z150, 0x012, 0, 0)
600    m000()
601    CH03(ts, z150, 0x013, 0, 0)
602}
603
604/*
605 * Valid sequence of requests, no exceptions expected.
606 *
607 * Acquire mutexes of monotone increasing level (Global lock
608 * on level 0 too) for all available levels from 0 up to 15,
609 * then Release them all in the inverse order.
610 *
611 * Exactly m301 but additioanlly:
612 *    all Acquire and Release opreations are located into separate methods.
613 */
614Method(m36b,, Serialized)
615{
616    Mutex(MT00, 0)
617    Mutex(MT10, 1)
618    Mutex(MT20, 2)
619    Mutex(MT30, 3)
620    Mutex(MT40, 4)
621    Mutex(MT50, 5)
622    Mutex(MT60, 6)
623    Mutex(MT70, 7)
624    Mutex(MT80, 8)
625    Mutex(MT90, 9)
626    Mutex(MTa0, 10)
627    Mutex(MTb0, 11)
628    Mutex(MTc0, 12)
629    Mutex(MTd0, 13)
630    Mutex(MTe0, 14)
631    Mutex(MTf0, 15)
632
633    Name(ts, "m36b")
634
635    Method(m000)
636    {
637
638    Store(Acquire(MT00, 0xffff), Local0)
639    if (Local0) {
640        err(ts, z150, 1, 0, 0, 0, Local0)
641    } else {
642    Store(Acquire(\_GL, 0xffff), Local0)
643    if (Local0) {
644        err(ts, z150, 2, 0, 0, 0, Local0)
645    } else {
646        Store(Acquire(MT10, 0xffff), Local0)
647        if (Local0) {
648            err(ts, z150, 3, 0, 0, 0, Local0)
649        } else {
650            Store(Acquire(MT20, 0xffff), Local0)
651            if (Local0) {
652                err(ts, z150, 4, 0, 0, 0, Local0)
653            } else {
654                Store(Acquire(MT30, 0xffff), Local0)
655                if (Local0) {
656                    err(ts, z150, 5, 0, 0, 0, Local0)
657                } else {
658                    Store(Acquire(MT40, 0xffff), Local0)
659                    if (Local0) {
660                        err(ts, z150, 6, 0, 0, 0, Local0)
661                    } else {
662                        Store(Acquire(MT50, 0xffff), Local0)
663                        if (Local0) {
664                            err(ts, z150, 7, 0, 0, 0, Local0)
665                        } else {
666                            Store(Acquire(MT60, 0xffff), Local0)
667                            if (Local0) {
668                                err(ts, z150, 8, 0, 0, 0, Local0)
669                            } else {
670                                Store(Acquire(MT70, 0xffff), Local0)
671                                if (Local0) {
672                                    err(ts, z150, 9, 0, 0, 0, Local0)
673                                } else {
674                                    Store(Acquire(MT80, 0xffff), Local0)
675                                    if (Local0) {
676                                        err(ts, z150, 0x00a, 0, 0, 0, Local0)
677                                    } else {
678                                        Store(Acquire(MT90, 0xffff), Local0)
679                                        if (Local0) {
680                                            err(ts, z150, 0x00b, 0, 0, 0, Local0)
681                                        } else {
682                                            Store(Acquire(MTa0, 0xffff), Local0)
683                                            if (Local0) {
684                                                err(ts, z150, 0x00c, 0, 0, 0, Local0)
685                                            } else {
686                                                Store(Acquire(MTb0, 0xffff), Local0)
687                                                if (Local0) {
688                                                    err(ts, z150, 0x00d, 0, 0, 0, Local0)
689                                                } else {
690                                                    Store(Acquire(MTc0, 0xffff), Local0)
691                                                    if (Local0) {
692                                                        err(ts, z150, 0x00e, 0, 0, 0, Local0)
693                                                    } else {
694                                                        Store(Acquire(MTd0, 0xffff), Local0)
695                                                        if (Local0) {
696                                                            err(ts, z150, 0x00f, 0, 0, 0, Local0)
697                                                        } else {
698                                                            Store(Acquire(MTe0, 0xffff), Local0)
699                                                            if (Local0) {
700                                                                err(ts, z150, 0x010, 0, 0, 0, Local0)
701                                                            } else {
702                                                                Store(Acquire(MTf0, 0xffff), Local0)
703                                                                if (Local0) {
704                                                                    err(ts, z150, 0x011, 0, 0, 0, Local0)
705                                                                }
706                                                            }
707                                                        }
708                                                    }
709                                                }
710                                            }
711                                        }
712                                    }
713                                }
714                            }
715                        }
716                    }
717                }
718            }
719        }
720    }
721    }
722    } /* m000 */
723
724    Method(m001)
725    {
726		Release(MTF0)
727		Release(MTE0)
728		Release(MTD0)
729		Release(MTC0)
730		Release(MTB0)
731		Release(MTA0)
732		Release(MT90)
733		Release(MT80)
734		Release(MT70)
735		Release(MT60)
736		Release(MT50)
737		Release(MT40)
738		Release(MT30)
739		Release(MT20)
740		Release(MT10)
741		Release(\_GL)
742		Release(MT00)
743    }
744
745    CH03(ts, z150, 0x012, 0, 0)
746    m000()
747    CH03(ts, z150, 0x013, 0, 0)
748    m001()
749    CH03(ts, z150, 0x014, 0, 0)
750}
751
752/*
753 * Invalid sequence of Acquire operations:
754 *
755 *   1) Acquire N-th level mutex (N>=1):
756 *   2) Acquire:
757 *      - mutexes from 0 up to (N-1)-levels
758 *      - Global lock
759 *   3) exception AE_AML_MUTEX_ORDER is expected for each Acquire of (2)
760 */
761Method(m36c,, Serialized)
762{
763	Name(ts, "m36c")
764	Name(lpN0, 0)
765	Name(lpC0, 0)
766
767	/*
768	 * arg0 - level of mutex to be acquired first
769	 * arg1 - level of mutex to be acquired second
770	 * arg2 - 1 - acquire 0-level mutex instead of arg1
771	 *        2 - acquire Global lock   instead of arg1
772	 */
773	Method(m000, 3, Serialized)
774	{
775		/* Acquire the first mutex */
776
777		CH03(ts, z150, 0x000, 0, 0)
778		m36f(arg0, 0, 0, 0) // Acquire N-level mutex
779		CH03(ts, z150, 0x001, 0, 0)
780
781		/*
782		 * Attempt to Acquire the second mutex (exception is expected).
783		 *
784		 * It is supposed that the second acquired
785		 * is a mutex of level not greater than (N-1)
786		 */
787		Switch (ToInteger (arg2)) {
788			Case (1) {
789				m36f(0, 0, 1, 0) // Acquire 0 level mux
790			}
791			Case (2) {
792				m36f(GLLL, GLIX, 1, 0) // Acquire GL
793			}
794			Default {
795				m36f(arg1, 0, 1, 0) // Acquire arg1-level mux
796			}
797		}
798		CH04(ts, 0, 64, z150, 0x002, 0, 0) // AE_AML_MUTEX_ORDER
799
800		m388(arg0, 0, 0) // Release
801
802		CH03(ts, z150, 0x003, 0, 0)
803	}
804
805	/*
806	 * The second Acquires are run in range from 0 up to (N-1) levels
807	 *
808	 * arg0 - N level (to be in range from 1 up to 15)
809	 */
810	Method(m001, 1, Serialized)
811	{
812		Name(lpN0, 0)
813		Name(lpC0, 0)
814
815		Store(arg0, lpN0)
816		Store(0, lpC0)
817		While (lpN0) {
818			m000(arg0, lpC0, 0)
819			Decrement(lpN0)
820			Increment(lpC0)
821		}
822	}
823
824	/* From 1 up to 15 levels */
825
826	Subtract(max0, 1, lpN0)
827	Store(1, lpC0)
828	While (lpN0) {
829		if (lpC0) {
830			m001(lpC0)
831			m000(lpC0, 0, 1) // 0 level mux
832			m000(lpC0, 0, 2) // GL
833		}
834		Decrement(lpN0)
835		Increment(lpC0)
836	}
837}
838
839/*
840 * Exception on Release.
841 * Release mutex twice.
842 *
843 * Attempt to Release free mutex: Acquire, Release, Release.
844 * Exception is expected on the second Release.
845 * Do it for all level mutexes and Global lock too.
846 */
847Method(m389,, Serialized)
848{
849	Name(ts, "m389")
850	Name(lpN0, 0)
851	Name(lpC0, 0)
852
853	/* arg0 - level of mutex */
854	Method(m000, 1)
855	{
856		CH03(ts, z150, 0x000, 0, 0)
857		m36f(arg0, 0, 0, 0) // Acquire
858		m388(arg0, 0, 0) // Release
859		CH03(ts, z150, 0x001, 0, 0)
860
861		/* Attempt to Release free mutex */
862		m388(arg0, 0, 0) // Release
863		CH04(ts, 0, 65, z150, 0x002, 0, 0) // AE_AML_MUTEX_NOT_ACQUIRED
864
865		CH03(ts, z150, 0x003, 0, 0)
866		m36f(arg0, 0, 0, 0) // Acquire
867		m388(arg0, 0, 0) // Release
868		CH03(ts, z150, 0x004, 0, 0)
869	}
870
871	Store(max0, lpN0)
872	Store(0, lpC0)
873	While (lpN0) {
874		m000(lpC0)
875		Decrement(lpN0)
876		Increment(lpC0)
877	}
878
879	/* Separately for GL */
880
881	CH03(ts, z150, 0x005, 0, 0)
882	m36f(GLLL, GLIX, 0, 0) // Acquire
883	m388(GLLL, GLIX, 0) // Release
884	CH03(ts, z150, 0x006, 0, 0)
885
886	/* Attempt to Release free mutex */
887	m388(GLLL, GLIX, 0) // Release
888	CH04(ts, 0, 65, z150, 0x007, 0, 0) // AE_AML_MUTEX_NOT_ACQUIRED
889
890	CH03(ts, z150, 0x008, 0, 0)
891	m36f(GLLL, GLIX, 0, 0) // Acquire
892	m388(GLLL, GLIX, 0) // Release
893	CH03(ts, z150, 0x009, 0, 0)
894}
895
896/*
897 * Exception on Release.
898 * Attempt ot Release clean mutex which was never Acquired.
899 */
900Method(m07b,, Serialized)
901{
902	Name(ts, "m07b")
903
904	Mutex(T000, 0)
905	Mutex(T100, 1)
906	Mutex(T200, 2)
907	Mutex(T300, 3)
908	Mutex(T400, 4)
909	Mutex(T500, 5)
910	Mutex(T600, 6)
911	Mutex(T700, 7)
912	Mutex(T800, 8)
913	Mutex(T900, 9)
914	Mutex(Ta00, 10)
915	Mutex(Tb00, 11)
916	Mutex(Tc00, 12)
917	Mutex(Td00, 13)
918	Mutex(Te00, 14)
919	Mutex(Tf00, 15)
920
921	/* First time */
922
923	CH03(ts, z150, 0x000, 0, 0)
924	Release(T000)
925	CH04(ts, 0, 65, z150, 0x001, 0, 0) // AE_AML_MUTEX_NOT_ACQUIRED
926
927	CH03(ts, z150, 0x002, 0, 0)
928	Release(\_GL)
929	CH04(ts, 0, 65, z150, 0x003, 0, 0)
930
931	CH03(ts, z150, 0x004, 0, 0)
932	Release(T100)
933	CH04(ts, 0, 65, z150, 0x005, 0, 0)
934
935	CH03(ts, z150, 0x006, 0, 0)
936	Release(T200)
937	CH04(ts, 0, 65, z150, 0x007, 0, 0)
938
939	CH03(ts, z150, 0x008, 0, 0)
940	Release(T300)
941	CH04(ts, 0, 65, z150, 0x009, 0, 0)
942
943	CH03(ts, z150, 0x00a, 0, 0)
944	Release(T400)
945	CH04(ts, 0, 65, z150, 0x00b, 0, 0)
946
947	CH03(ts, z150, 0x00c, 0, 0)
948	Release(T500)
949	CH04(ts, 0, 65, z150, 0x00d, 0, 0)
950
951	CH03(ts, z150, 0x00e, 0, 0)
952	Release(T600)
953	CH04(ts, 0, 65, z150, 0x00f, 0, 0)
954
955	CH03(ts, z150, 0x010, 0, 0)
956	Release(T700)
957	CH04(ts, 0, 65, z150, 0x011, 0, 0)
958
959	CH03(ts, z150, 0x012, 0, 0)
960	Release(T800)
961	CH04(ts, 0, 65, z150, 0x013, 0, 0)
962
963	CH03(ts, z150, 0x014, 0, 0)
964	Release(T900)
965	CH04(ts, 0, 65, z150, 0x015, 0, 0)
966
967	CH03(ts, z150, 0x016, 0, 0)
968	Release(Ta00)
969	CH04(ts, 0, 65, z150, 0x017, 0, 0)
970
971	CH03(ts, z150, 0x018, 0, 0)
972	Release(Tb00)
973	CH04(ts, 0, 65, z150, 0x019, 0, 0)
974
975	CH03(ts, z150, 0x01a, 0, 0)
976	Release(Tc00)
977	CH04(ts, 0, 65, z150, 0x01b, 0, 0)
978
979	CH03(ts, z150, 0x01c, 0, 0)
980	Release(Td00)
981	CH04(ts, 0, 65, z150, 0x01d, 0, 0)
982
983	CH03(ts, z150, 0x01e, 0, 0)
984	Release(Te00)
985	CH04(ts, 0, 65, z150, 0x01f, 0, 0)
986
987	CH03(ts, z150, 0x020, 0, 0)
988	Release(Tf00)
989	CH04(ts, 0, 65, z150, 0x021, 0, 0)
990
991
992	/* Second time */
993
994	CH03(ts, z150, 0x022, 0, 0)
995	Release(T000)
996	CH04(ts, 0, 65, z150, 0x023, 0, 0) // AE_AML_MUTEX_NOT_ACQUIRED
997
998	CH03(ts, z150, 0x024, 0, 0)
999	Release(T100)
1000	CH04(ts, 0, 65, z150, 0x025, 0, 0)
1001
1002	CH03(ts, z150, 0x026, 0, 0)
1003	Release(T200)
1004	CH04(ts, 0, 65, z150, 0x027, 0, 0)
1005
1006	CH03(ts, z150, 0x028, 0, 0)
1007	Release(T300)
1008	CH04(ts, 0, 65, z150, 0x029, 0, 0)
1009
1010	CH03(ts, z150, 0x02a, 0, 0)
1011	Release(T400)
1012	CH04(ts, 0, 65, z150, 0x02b, 0, 0)
1013
1014	CH03(ts, z150, 0x02c, 0, 0)
1015	Release(T500)
1016	CH04(ts, 0, 65, z150, 0x02d, 0, 0)
1017
1018	CH03(ts, z150, 0x02e, 0, 0)
1019	Release(T600)
1020	CH04(ts, 0, 65, z150, 0x02f, 0, 0)
1021
1022	CH03(ts, z150, 0x030, 0, 0)
1023	Release(T700)
1024	CH04(ts, 0, 65, z150, 0x031, 0, 0)
1025
1026	CH03(ts, z150, 0x032, 0, 0)
1027	Release(T800)
1028	CH04(ts, 0, 65, z150, 0x033, 0, 0)
1029
1030	CH03(ts, z150, 0x034, 0, 0)
1031	Release(T900)
1032	CH04(ts, 0, 65, z150, 0x035, 0, 0)
1033
1034	CH03(ts, z150, 0x036, 0, 0)
1035	Release(Ta00)
1036	CH04(ts, 0, 65, z150, 0x037, 0, 0)
1037
1038	CH03(ts, z150, 0x038, 0, 0)
1039	Release(Tb00)
1040	CH04(ts, 0, 65, z150, 0x039, 0, 0)
1041
1042	CH03(ts, z150, 0x03a, 0, 0)
1043	Release(Tc00)
1044	CH04(ts, 0, 65, z150, 0x03b, 0, 0)
1045
1046	CH03(ts, z150, 0x03c, 0, 0)
1047	Release(Td00)
1048	CH04(ts, 0, 65, z150, 0x03d, 0, 0)
1049
1050	CH03(ts, z150, 0x03e, 0, 0)
1051	Release(Te00)
1052	CH04(ts, 0, 65, z150, 0x03f, 0, 0)
1053
1054	CH03(ts, z150, 0x040, 0, 0)
1055	Release(Tf00)
1056	CH04(ts, 0, 65, z150, 0x041, 0, 0)
1057}
1058
1059/*
1060 * Exception on Release.
1061 * Break the sequence of Acquiring mutexes while Releasing them,
1062 * jump over the level.
1063 *
1064 * Invalid sequence of Releases:
1065 *
1066 *   1) Take level from range (N>=1 & N<=15)
1067 *   2) Acquire mutexes of all levels from 0 up to N
1068 *   3) Try to Release any mutex:
1069 *      - in the level range from (N-1) down to 0
1070 *      - Global lock
1071 *   4) Do 1-3 for all levels in range (N>=1 & N<=15)
1072 */
1073Method(m38a,, Serialized)
1074{
1075	Name(lpN0, 0)
1076	Name(lpC0, 0)
1077	Name(br00, 0)
1078
1079
1080	Subtract(max0, 1, lpN0)
1081	Store(2, lpC0)
1082
1083	While (lpN0) {
1084
1085		/* Acquire lpC0 levels from 0 level */
1086
1087		m38b(0, lpC0, 1, 0)
1088
1089
1090		/*
1091		 * Exception is expected on each Release there.
1092		 *
1093		 * Break the sequence of Acquiring mutexes while Releasing them,
1094		 * jump over the level.
1095		 * Run Releasing mutexes NOT from (lpC0-1) level which whould be
1096		 * correct but from (lpC0-2) level down to 0 level so jumping over
1097		 * the mutex of (lpC0-1) level which is Acquired which should cause
1098		 * each of these Releases to generate AE_AML_MUTEX_ORDER exception.
1099		 */
1100		Subtract(lpC0, 2, Local0)
1101		Subtract(lpC0, 1, Local1)
1102		if (m38c(Local0, Local1, 1, 64)) { // AE_AML_MUTEX_ORDER
1103			/*
1104			 * Break for the first bunch of errors encountered,
1105			 * dont waste log.
1106			 */
1107			Store(1, br00)
1108		}
1109
1110
1111		/*
1112		 * Correct sequence of Releases.
1113		 * Release lpC0 levels from (lpC0-1) down to 0 level.
1114		 */
1115
1116		if (br00) {
1117			m36f(hlmx, 0, 0, 0)
1118			m388(hlmx, 0, 0)
1119		}
1120		Subtract(lpC0, 1, Local0)
1121		m38c(Local0, lpC0, 1, 0)
1122
1123		if (br00) {
1124			break
1125		}
1126
1127		Decrement(lpN0)
1128		Increment(lpC0)
1129	}
1130
1131	CH03("m38a", z150, 0x000, 0, 0)
1132}
1133
1134/*
1135 * Manager for m38d.
1136 *
1137 * arg0 - the value of flag of GL
1138 * arg1 - order of Releasing bitmap (see m089)
1139 */
1140Method(m08c, 2, Serialized)
1141{
1142	Name(lpN0, 0)
1143	Name(lpC0, 0)
1144
1145	/*
1146	 * arg0 - Level of mutex
1147	 * arg1 - the value of flag of GL
1148	 * arg2 - order of Releasing bitmap (see m089)
1149	 */
1150	Method(m000, 3)
1151	{
1152		/* Set up the value of flag of Global lock */
1153		Store(m078(arg1), Local7)
1154
1155		/*
1156		 * min0 - number of mutexes existent for each level
1157		 *
1158		 * Acquire mutexes of level arg0
1159		 * in the order from 0 index up
1160		 * to (min0-1) one, then Release
1161		 * them in the order specified
1162		 * by arg2.
1163		 */
1164		m088(arg0, 1, 0, min0, 0, 0, 0)    // Acquire
1165		m089(arg0, 1, 0, min0, 0, 0, arg2) // Release
1166
1167		/* Restore the value of flag of Global lock */
1168		m078(Local7)
1169	}
1170
1171	/* For each level */
1172	Store(max0, lpN0)
1173	Store(0, lpC0)
1174
1175	While (lpN0) {
1176		m000(lpC0, arg0, arg1)
1177		Decrement(lpN0)
1178		Increment(lpC0)
1179	}
1180
1181}
1182
1183/*
1184 * Check up that the Releasing of the same level mutexes
1185 * can be performed in an arbitrary order, independently
1186 * on the order they were Acquired.
1187 *
1188 * For each level separately, one by one.
1189 */
1190Method(m38d)
1191{
1192	m08c(0, 0x0000) // direct  order of Releasing, Mutex(0,1) is usual mutex
1193	m08c(0, 0x0001) // inverse order of Releasing, Mutex(0,1) is usual mutex
1194	m08c(1, 0x0000) // direct  order of Releasing, Mutex(0,1) is GL
1195	m08c(1, 0x0001) // inverse order of Releasing, Mutex(0,1) is GL
1196
1197	/* Check that all mutexes are Released */
1198	m08a()
1199}
1200
1201/*
1202 * Check up that the Releasing of the same level mutexes
1203 * can be performed in an arbitrary order, independently
1204 * on the order they were Acquired.
1205 *
1206 * Cross through all the levels.
1207 *
1208 * arg0 - order of Releasing bitmap (see m089)
1209 */
1210Method(m07d, 1)
1211{
1212	m088(0, max0, 0, min0, 0, 0, 0)    // Acquire all mutexes on all levels
1213	m089(0, max0, 0, min0, 0, 0, arg0) // Release all mutexes on all levels
1214}
1215
1216/*
1217 * ACPI allows multiply own the same mutex
1218 *
1219 * arg0 - the value of flag of GL
1220 */
1221Method(m07a, 1)
1222{
1223	m079(10, arg0)
1224}
1225
1226/*
1227 * Multiply owning the same ACPI mutex.
1228 * Acquire the same mutex arg2 times, then Release it (arg2+1) times,
1229 * expect exception on the last Release.
1230 * The repeated Acquire are made with TimeoutValue equal to zero.
1231 *
1232 * arg0 - how many times to Acquire it
1233 * arg1 - the value of flag of GL
1234 */
1235Method(m079, 2, Serialized)
1236{
1237	Name(ts, "m079")
1238	Name(lpN0, 0)
1239	Name(lpC0, 0)
1240	Name(lpN1, 0)
1241	Name(lpC1, 0)
1242	Name(tout, 0)
1243	Name(ix00, 1)
1244
1245	/* Set up the value of flag of Global lock */
1246	Store(m078(arg1), Local7)
1247
1248	/* Acquire */
1249
1250	/* levels */
1251
1252	Store(max0, lpN0)
1253	Store(0, lpC0)
1254	While (lpN0) {
1255		/* repetitions */
1256		Store(arg0, lpN1)
1257		Store(0, lpC1)
1258		While (lpN1) {
1259			if (lpC1) {
1260				Store(TOV0, tout) // TimeOutValue equal to 0
1261			} else {
1262				Store(0, tout) // TimeOutValue equal to 0xffff (once for the first Acquire)
1263			}
1264			m36f(lpC0, ix00, 0, tout)
1265			Decrement(lpN1)
1266			Increment(lpC1)
1267		}
1268		Decrement(lpN0)
1269		Increment(lpC0)
1270	}
1271
1272	/* Release */
1273
1274	CH03(ts, z150, 0x000, 0, 0)
1275
1276	Store(max0, lpN0)
1277	Subtract(max0, 1, lpC0)
1278	While (lpN0) {
1279		/* repetitions */
1280		Store(arg0, lpN1)
1281		Store(0, lpC1)
1282		While (lpN1) {
1283			m388(lpC0, ix00, 0)
1284			Decrement(lpN1)
1285			Increment(lpC1)
1286		}
1287		Decrement(lpN0)
1288		Decrement(lpC0)
1289	}
1290
1291	/* The 'owning counters' are exhausted, so exceptions are expected */
1292
1293	Store(max0, lpN0)
1294	Subtract(max0, 1, lpC0)
1295	While (lpN0) {
1296		CH03(ts, z150, 0x001, 0, 0)
1297		m388(lpC0, ix00, 0)
1298		CH04(ts, 0, 65, z150, 0x002, 0, 0) // AE_AML_MUTEX_NOT_ACQUIRED
1299		Decrement(lpN0)
1300		Decrement(lpC0)
1301	}
1302
1303	/* Restore the value of flag of Global lock */
1304	m078(Local7)
1305}
1306
1307
1308/*
1309 * /////////////////////////////////////////
1310 *
1311 *    The tests below examine different ways
1312 *    to Acquire/Release mutexes
1313 *
1314 * /////////////////////////////////////////
1315 */
1316
1317/*
1318 * ATTENTION: this test must be run the first
1319 *
1320 * Different ways to Acquire/Release mutexes
1321 *
1322 * 1) Acquire and Release operations are in a global level AML code
1323 *
1324 * See m07c.
1325 */
1326Method(m0b9,, Serialized)
1327{
1328	Name(ts, "m0b9")
1329
1330	/* i101 - non-zero means that the test was run */
1331	if (LNot(i101)) {
1332		return
1333	}
1334
1335	CH03(ts, z150, 0x000, 0, 0)
1336
1337}
1338
1339/*
1340 * The same operations as m0b9 (the test for global level AML code)
1341 * but enclosed into Method.
1342 */
1343Method(m0bb,, Serialized)
1344{
1345	Name(ts, "m0bb")
1346
1347	CH03(ts, z150, 0x000, 0, 0)
1348
1349	Method(m137)
1350	{
1351		Store("m137 started", Debug)
1352
1353		if (LNot(i102)) {
1354			Release(T804)
1355		}
1356
1357		Store("m137 completed", Debug)
1358
1359		return (1)
1360	}
1361	Method(m13e)
1362	{
1363		Store("m13e started", Debug)
1364
1365		Store(Acquire(T805, 0xffff), i103)
1366		if (i103) {
1367			err(ts, z150, 0x001, 0, 0, 0, i103)
1368		}
1369
1370		Store("m13e completed", Debug)
1371
1372		return (1)
1373	}
1374	Method(m13f)
1375	{
1376		Store("m13f started", Debug)
1377
1378		if (LNot(i103)) {
1379			Release(T805)
1380		}
1381
1382		Store("m13f completed", Debug)
1383
1384		return (1)
1385	}
1386
1387
1388	Name(i102, 1)
1389	Name(i103, 1)
1390	Name(b11c, Buffer(Add(1, Store(Acquire(T804, 0xffff), i102))){0})
1391	Name(b11d, Buffer(m137()){0})
1392	Name(b11e, Buffer(m13e()){0})
1393	Name(b11f, Buffer(m13f()){0})
1394
1395	if (i102) {
1396		Store("Acquire(T804, 0xffff) failed", Debug)
1397		err(ts, z150, 0x002, 0, 0, 0, i102)
1398	}
1399
1400	if (i103) {
1401		Store("Acquire(T805, 0xffff) failed", Debug)
1402		err(ts, z150, 0x003, 0, 0, 0, i103)
1403	}
1404
1405	CH03(ts, z150, 0x004, 0, 0)
1406}
1407
1408/*
1409 * Different ways to Acquire/Release mutexes
1410 *
1411 * 2) Acquire and Release operations are in the same method
1412 * 3) Acquire and Release operations are in different methods
1413 *
1414 * See m0b9.
1415 */
1416Method(m07c,, Serialized)
1417{
1418	Name(ts, "m07c")
1419
1420	/* Acquire and Release operations are in the same method */
1421	Method(m000)
1422	{
1423			CH03(ts, z150, 0x000, 0, 0)
1424
1425			/* Acquire all */
1426
1427			Store(Acquire(\_GL, 0xffff), Local0)
1428			if (Local0) {
1429				err(ts, z150, 0x000, 0, 0, 0, Local0)
1430			}
1431
1432			Store(Acquire(T000, 0xffff), Local0)
1433			if (Local0) {
1434				err(ts, z150, 0x000, 0, 0, 0, Local0)
1435			}
1436
1437			Store(Acquire(T100, 0xffff), Local0)
1438			if (Local0) {
1439				err(ts, z150, 0x000, 0, 0, 0, Local0)
1440			}
1441
1442			Store(Acquire(T200, 0xffff), Local0)
1443			if (Local0) {
1444				err(ts, z150, 0x000, 0, 0, 0, Local0)
1445			}
1446
1447			Store(Acquire(T300, 0xffff), Local0)
1448			if (Local0) {
1449				err(ts, z150, 0x000, 0, 0, 0, Local0)
1450			}
1451
1452			Store(Acquire(T400, 0xffff), Local0)
1453			if (Local0) {
1454				err(ts, z150, 0x000, 0, 0, 0, Local0)
1455			}
1456
1457			Store(Acquire(T500, 0xffff), Local0)
1458			if (Local0) {
1459				err(ts, z150, 0x000, 0, 0, 0, Local0)
1460			}
1461
1462			Store(Acquire(T600, 0xffff), Local0)
1463			if (Local0) {
1464				err(ts, z150, 0x000, 0, 0, 0, Local0)
1465			}
1466
1467			Store(Acquire(T700, 0xffff), Local0)
1468			if (Local0) {
1469				err(ts, z150, 0x000, 0, 0, 0, Local0)
1470			}
1471
1472			Store(Acquire(T800, 0xffff), Local0)
1473			if (Local0) {
1474				err(ts, z150, 0x000, 0, 0, 0, Local0)
1475			}
1476
1477			Store(Acquire(T900, 0xffff), Local0)
1478			if (Local0) {
1479				err(ts, z150, 0x000, 0, 0, 0, Local0)
1480			}
1481
1482			Store(Acquire(Ta00, 0xffff), Local0)
1483			if (Local0) {
1484				err(ts, z150, 0x000, 0, 0, 0, Local0)
1485			}
1486
1487			Store(Acquire(Tb00, 0xffff), Local0)
1488			if (Local0) {
1489				err(ts, z150, 0x000, 0, 0, 0, Local0)
1490			}
1491
1492			Store(Acquire(Tc00, 0xffff), Local0)
1493			if (Local0) {
1494				err(ts, z150, 0x000, 0, 0, 0, Local0)
1495			}
1496
1497			Store(Acquire(Td00, 0xffff), Local0)
1498			if (Local0) {
1499				err(ts, z150, 0x000, 0, 0, 0, Local0)
1500			}
1501
1502			Store(Acquire(Te00, 0xffff), Local0)
1503			if (Local0) {
1504				err(ts, z150, 0x000, 0, 0, 0, Local0)
1505			}
1506
1507			Store(Acquire(Tf00, 0xffff), Local0)
1508			if (Local0) {
1509				err(ts, z150, 0x000, 0, 0, 0, Local0)
1510			}
1511
1512			CH03(ts, z150, 0x000, 0, 0)
1513
1514			/* Release all */
1515
1516			Release(Tf00)
1517			Release(Te00)
1518			Release(Td00)
1519			Release(Tc00)
1520			Release(Tb00)
1521			Release(Ta00)
1522			Release(T900)
1523			Release(T800)
1524			Release(T700)
1525			Release(T600)
1526			Release(T500)
1527			Release(T400)
1528			Release(T300)
1529			Release(T200)
1530			Release(T100)
1531			Release(T000)
1532			Release(\_GL)
1533
1534			CH03(ts, z150, 0x000, 0, 0)
1535	}
1536
1537	/* Acquire and Release operations are in different methods */
1538	Method(m001)
1539	{
1540		Method(mm00)
1541		{
1542			CH03(ts, z150, 0x000, 0, 0)
1543
1544			Store(Acquire(\_GL, 0xffff), Local0)
1545			if (Local0) {
1546				err(ts, z150, 0x000, 0, 0, 0, Local0)
1547			}
1548
1549			Store(Acquire(T000, 0xffff), Local0)
1550			if (Local0) {
1551				err(ts, z150, 0x000, 0, 0, 0, Local0)
1552			}
1553
1554			Store(Acquire(T100, 0xffff), Local0)
1555			if (Local0) {
1556				err(ts, z150, 0x000, 0, 0, 0, Local0)
1557			}
1558
1559			Store(Acquire(T200, 0xffff), Local0)
1560			if (Local0) {
1561				err(ts, z150, 0x000, 0, 0, 0, Local0)
1562			}
1563
1564			Store(Acquire(T300, 0xffff), Local0)
1565			if (Local0) {
1566				err(ts, z150, 0x000, 0, 0, 0, Local0)
1567			}
1568
1569			Store(Acquire(T400, 0xffff), Local0)
1570			if (Local0) {
1571				err(ts, z150, 0x000, 0, 0, 0, Local0)
1572			}
1573
1574			Store(Acquire(T500, 0xffff), Local0)
1575			if (Local0) {
1576				err(ts, z150, 0x000, 0, 0, 0, Local0)
1577			}
1578
1579			Store(Acquire(T600, 0xffff), Local0)
1580			if (Local0) {
1581				err(ts, z150, 0x000, 0, 0, 0, Local0)
1582			}
1583
1584			Store(Acquire(T700, 0xffff), Local0)
1585			if (Local0) {
1586				err(ts, z150, 0x000, 0, 0, 0, Local0)
1587			}
1588
1589			Store(Acquire(T800, 0xffff), Local0)
1590			if (Local0) {
1591				err(ts, z150, 0x000, 0, 0, 0, Local0)
1592			}
1593
1594			Store(Acquire(T900, 0xffff), Local0)
1595			if (Local0) {
1596				err(ts, z150, 0x000, 0, 0, 0, Local0)
1597			}
1598
1599			Store(Acquire(Ta00, 0xffff), Local0)
1600			if (Local0) {
1601				err(ts, z150, 0x000, 0, 0, 0, Local0)
1602			}
1603
1604			Store(Acquire(Tb00, 0xffff), Local0)
1605			if (Local0) {
1606				err(ts, z150, 0x000, 0, 0, 0, Local0)
1607			}
1608
1609			Store(Acquire(Tc00, 0xffff), Local0)
1610			if (Local0) {
1611				err(ts, z150, 0x000, 0, 0, 0, Local0)
1612			}
1613
1614			Store(Acquire(Td00, 0xffff), Local0)
1615			if (Local0) {
1616				err(ts, z150, 0x000, 0, 0, 0, Local0)
1617			}
1618
1619			Store(Acquire(Te00, 0xffff), Local0)
1620			if (Local0) {
1621				err(ts, z150, 0x000, 0, 0, 0, Local0)
1622			}
1623
1624			Store(Acquire(Tf00, 0xffff), Local0)
1625			if (Local0) {
1626				err(ts, z150, 0x000, 0, 0, 0, Local0)
1627			}
1628
1629			CH03(ts, z150, 0x000, 0, 0)
1630		}
1631
1632		Method(mm01)
1633		{
1634			CH03(ts, z150, 0x000, 0, 0)
1635
1636			Release(Tf00)
1637			Release(Te00)
1638			Release(Td00)
1639			Release(Tc00)
1640			Release(Tb00)
1641			Release(Ta00)
1642			Release(T900)
1643			Release(T800)
1644			Release(T700)
1645			Release(T600)
1646			Release(T500)
1647			Release(T400)
1648			Release(T300)
1649			Release(T200)
1650			Release(T100)
1651			Release(T000)
1652			Release(\_GL)
1653
1654			CH03(ts, z150, 0x000, 0, 0)
1655		}
1656
1657		Method(mm02)
1658		{
1659			CH03(ts, z150, 0x000, 0, 0)
1660			Release(Tf00)
1661			CH04(ts, 0, 65, z150, 0x001, 0, 0) // AE_AML_MUTEX_NOT_ACQUIRED
1662			CH03(ts, z150, 0x002, 0, 0)
1663			Release(Te00)
1664			CH04(ts, 0, 65, z150, 0x003, 0, 0) // AE_AML_MUTEX_NOT_ACQUIRED
1665			CH03(ts, z150, 0x004, 0, 0)
1666			Release(Td00)
1667			CH04(ts, 0, 65, z150, 0x005, 0, 0) // AE_AML_MUTEX_NOT_ACQUIRED
1668			CH03(ts, z150, 0x006, 0, 0)
1669			Release(Tc00)
1670			CH04(ts, 0, 65, z150, 0x007, 0, 0) // AE_AML_MUTEX_NOT_ACQUIRED
1671			CH03(ts, z150, 0x008, 0, 0)
1672			Release(Tb00)
1673			CH04(ts, 0, 65, z150, 0x009, 0, 0) // AE_AML_MUTEX_NOT_ACQUIRED
1674			CH03(ts, z150, 0x00a, 0, 0)
1675			Release(Ta00)
1676			CH04(ts, 0, 65, z150, 0x00b, 0, 0) // AE_AML_MUTEX_NOT_ACQUIRED
1677			CH03(ts, z150, 0x00c, 0, 0)
1678			Release(T900)
1679			CH04(ts, 0, 65, z150, 0x00d, 0, 0) // AE_AML_MUTEX_NOT_ACQUIRED
1680			CH03(ts, z150, 0x00e, 0, 0)
1681			Release(T800)
1682			CH04(ts, 0, 65, z150, 0x00f, 0, 0) // AE_AML_MUTEX_NOT_ACQUIRED
1683			CH03(ts, z150, 0x010, 0, 0)
1684			Release(T700)
1685			CH04(ts, 0, 65, z150, 0x011, 0, 0) // AE_AML_MUTEX_NOT_ACQUIRED
1686			CH03(ts, z150, 0x012, 0, 0)
1687			Release(T600)
1688			CH04(ts, 0, 65, z150, 0x013, 0, 0) // AE_AML_MUTEX_NOT_ACQUIRED
1689			CH03(ts, z150, 0x014, 0, 0)
1690			Release(T500)
1691			CH04(ts, 0, 65, z150, 0x015, 0, 0) // AE_AML_MUTEX_NOT_ACQUIRED
1692			CH03(ts, z150, 0x016, 0, 0)
1693			Release(T400)
1694			CH04(ts, 0, 65, z150, 0x017, 0, 0) // AE_AML_MUTEX_NOT_ACQUIRED
1695			CH03(ts, z150, 0x018, 0, 0)
1696			Release(T300)
1697			CH04(ts, 0, 65, z150, 0x019, 0, 0) // AE_AML_MUTEX_NOT_ACQUIRED
1698			CH03(ts, z150, 0x01a, 0, 0)
1699			Release(T200)
1700			CH04(ts, 0, 65, z150, 0x01b, 0, 0) // AE_AML_MUTEX_NOT_ACQUIRED
1701			CH03(ts, z150, 0x01c, 0, 0)
1702			Release(T100)
1703			CH04(ts, 0, 65, z150, 0x01d, 0, 0) // AE_AML_MUTEX_NOT_ACQUIRED
1704			CH03(ts, z150, 0x01e, 0, 0)
1705			Release(T000)
1706			CH04(ts, 0, 65, z150, 0x01f, 0, 0) // AE_AML_MUTEX_NOT_ACQUIRED
1707			CH03(ts, z150, 0x020, 0, 0)
1708			Release(\_GL)
1709			CH04(ts, 0, 65, z150, 0x021, 0, 0) // AE_AML_MUTEX_NOT_ACQUIRED
1710		}
1711
1712		mm00()
1713		mm01()
1714		mm02()
1715	}
1716
1717	/* Acquire and Release operations are in the same method */
1718	m000()
1719
1720	/* Acquire and Release operations are in different methods */
1721	m001()
1722}
1723
1724/*
1725 * Acquire/Release operations enclosed in other operations
1726 */
1727Method(m0ba,, Serialized)
1728{
1729	Name(ts, "m0ba")
1730
1731	CH03(ts, z150, 0x000, 0, 0)
1732
1733	/* Add */
1734
1735	Add(Acquire(\_GL, 0xffff), 1, Local0)
1736	if (LNotEqual(Local0, 1)) {
1737		err(ts, z150, 0x001, 0, 0, 0, Local0)
1738	}
1739
1740	Add(Acquire(T500, 0xffff), 1, Local0)
1741	if (LNotEqual(Local0, 1)) {
1742		err(ts, z150, 0x002, 0, 0, 0, Local0)
1743	}
1744
1745	Release(T500)
1746	Release(\_GL)
1747
1748	/* Subtract */
1749
1750	Subtract(1, Acquire(\_GL, 0xffff), Local0)
1751	if (LNotEqual(Local0, 1)) {
1752		err(ts, z150, 0x003, 0, 0, 0, Local0)
1753	}
1754
1755	Subtract(1, Acquire(T500, 0xffff), Local0)
1756	if (LNotEqual(Local0, 1)) {
1757		err(ts, z150, 0x004, 0, 0, 0, Local0)
1758	}
1759
1760	Release(T500)
1761	Release(\_GL)
1762
1763	/* LEqual */
1764
1765	if (LNotEqual(Acquire(T500, 0xffff), 0)) {
1766		err(ts, z150, 0x004, 0, 0, 0, Local0)
1767	}
1768	Release(T500)
1769
1770	if (FL03) {
1771		// Check that all mutexes are Released (doesn't check T804..)
1772		m08a()
1773	}
1774	CH04 (ts, 1, 64, z150, 0x001, 0, 0)
1775}
1776
1777/*
1778 * /////////////////////////////////////////////
1779 *
1780 *    The tests below generate some combinations
1781 *    of Acquire/Release operations
1782 *
1783 * /////////////////////////////////////////////
1784 */
1785
1786/*
1787 * Get 0 or 1 value pseudo randomly
1788 *
1789 * arg0 - input Integer
1790 */
1791Method(m08e)
1792{
1793	/* To be improved */
1794
1795	And(cn00, 0x01, Local0)
1796
1797	Increment(cn00)
1798
1799	if (LNot(y242)) {
1800		/* Always inverse order untill the bug 242 is fixes */
1801		Store(0x0001, Local0)
1802	}
1803
1804	return (Local0)
1805}
1806
1807/*
1808 * Acquire/Release combination #1
1809 */
1810Method(m07e,, Serialized)
1811{
1812	Name(num, 4)
1813	Name(rpt0, 0)
1814	Name(rpt1, 3)
1815	Name(lpN0, 0)
1816	Name(lpC0, 0)
1817
1818
1819	/* Set up the value of flag of Global lock */
1820	Store(m078(0), Local7)
1821
1822	Store(num, lpN0)
1823	Store(0, lpC0)
1824	While (lpN0) {
1825
1826		/* Set up the value of flag of Global lock */
1827		Divide(lpC0, 2, Local0)
1828		m078(Local0)
1829
1830		if (Local0) {
1831			Store(rpt1, rpt0)
1832		} else {
1833			Store(1, rpt0)
1834		}
1835
1836		m088( 0,  3, 0, 4, 0, rpt0, 0)      // Step  0, Acquire
1837		m088( 3,  3, 1, 2, 0, rpt0, 0)      // Step  1, Acquire
1838		m089( 4,  2, 1, 2, 0, rpt0, m08e()) // Step  1, Release
1839		m088( 5,  3, 0, 4, 0, rpt0, 0)      // Step  2, Acquire
1840		m089( 7,  1, 1, 3, 0, rpt0, m08e()) // Step  2, Release
1841		m089( 7,  1, 0, 1, 0, rpt0, m08e()) // Step  2, Release
1842		m089( 6,  1, 0, 4, 0, rpt0, m08e()) // Step  2, Release
1843		m088( 9,  2, 2, 2, 0, rpt0, 0)      // Step  3, Acquire
1844		m089(10,  1, 3, 1, 0, rpt0, m08e()) // Step  3, Release
1845		m089(10,  1, 2, 1, 0, rpt0, m08e()) // Step  3, Release
1846		m089( 9,  1, 3, 1, 0, rpt0, m08e()) // Step  3, Release
1847		m088(10,  2, 0, 3, 0, rpt0, 0)      // Step  4, Acquire
1848		m089(10,  2, 0, 3, 0, rpt0, m08e()) // Step  4, Release
1849		m088(10,  2, 0, 3, 0, rpt0, 0)      // Step  5, Acquire
1850		m089(10,  2, 0, 3, 0, rpt0, m08e()) // Step  5, Release
1851		m088(12,  2, 0, 3, 0, rpt0, 0)      // Step  6, Acquire
1852		m089(12,  2, 0, 3, 0, rpt0, m08e()) // Step  6, Release
1853		m088(10,  6, 0, 4, 0, rpt0, 0)      // Step  7, Acquire
1854		m089(10,  6, 0, 4, 0, rpt0, m08e()) // Step  7, Release
1855		m088(12,  2, 0, 3, 0, rpt0, 0)      // Step  8, Acquire
1856		m089(12,  2, 0, 3, 0, rpt0, m08e()) // Step  8, Release
1857		m089( 9,  1, 2, 1, 0, rpt0, m08e()) // Step  3, Release
1858		m089( 5,  1, 0, 4, 0, rpt0, m08e()) // Step  2, Release
1859		m089( 3,  1, 1, 2, 0, rpt0, m08e()) // Step  1, Release
1860		m089( 1,  2, 0, 4, 0, rpt0, m08e()) // Step  0, Release
1861		m088( 1, 15, 1, 2, 0, rpt0, 0)      // Step  9, Acquire
1862		m089( 1, 15, 1, 2, 0, rpt0, m08e()) // Step  9, Release
1863		m089( 0,  1, 1, 1, 0, rpt0, m08e()) // Step  0, Release
1864		m089( 0,  1, 3, 1, 0, rpt0, m08e()) // Step  0, Release
1865		m089( 0,  1, 2, 1, 0, rpt0, m08e()) // Step  0, Release
1866		m089( 0,  1, 0, 1, 0, rpt0, m08e()) // Step  0, Release
1867		m088( 0, 16, 1, 2, 0, rpt0, 0)      // Step 10, Acquire
1868		m089( 0, 16, 1, 2, 0, rpt0, m08e()) // Step 10, Release
1869
1870		Decrement(lpN0)
1871		Increment(lpC0)
1872	}
1873
1874	/* Restore the value of flag of Global lock */
1875	m078(Local7)
1876
1877	if (FL03) {
1878		// Check that all mutexes are Released
1879		m08a()
1880	}
1881}
1882
1883/*
1884 * ///////////////////////////////////////////////////
1885 *
1886 *    The tests below check behaviour after exceptions
1887 *
1888 * ///////////////////////////////////////////////////
1889 */
1890
1891/*
1892 * Check the life after AE_AML_MUTEX_ORDER exception on Acquire
1893 *
1894 *  1)     Acquire     N-th level mutex MUX-N
1895 *  2) run Acquire (N-2)-th level mutex MUX-(N-2) and get AE_AML_MUTEX_ORDER exception
1896 *  3) run Acquire (N-1)-th level mutex MUX-(N-1) and get AE_AML_MUTEX_ORDER exception
1897 *  4)     Acquire                mutex MUX-N and check that no exception on this operation
1898 *  5)     Release                mutex MUX-N and check that no exception on this operation
1899 *  6)     Release                mutex MUX-N and check that no exception on this operation
1900 *  7)     do 1-6 for all N in range 2-15 levels
1901 *  8)     check additionally that all the mutexes are free (run Release and
1902 *         get AE_AML_MUTEX_NOT_ACQUIRED exception for all the mutexes of all levels)
1903 *  9)     Acquire all mutexes of all levels and check that no exceptions
1904 * 10)     Release all mutexes of all levels and check that no exceptions
1905 * 11)     check additionally that all the mutexes are free (see 8)
1906 *
1907 * 12)     do it for GL mode too
1908 * 13)     do additional Acquire of MUX-(N-2) and MUX-(N-1) before Acquire of MUX-N (Release them later)
1909 *
1910 * arg0 - the value of flag of GL
1911 * arg1 - if non-zero do additional Acquire of MUX-(N-2) and MUX-(N-1) before Acquire of MUX-N
1912 */
1913Method(m08b, 2, Serialized)
1914{
1915	Name(rpt0, 1)
1916	Name(ord0, 0x0001)
1917
1918	Name(lpN0, 0) // level
1919	Name(lpC0, 0)
1920
1921	/* Set up the value of flag of Global lock */
1922	Store(m078(arg0), Local7)
1923
1924	Subtract(max0, 2, lpN0)
1925	Store(2, lpC0)
1926	While (lpN0) {
1927
1928		Subtract(lpC0, 1, Local0)
1929		Subtract(lpC0, 2, Local1)
1930
1931		if (arg1) {
1932		m088( Local1, 1, 0, 4,  0, rpt0, 0)    // Step -2, Acquire
1933		m088( Local0, 1, 0, 4,  0, rpt0, 0)    // Step -1, Acquire
1934		}
1935
1936		m088( lpC0,   1, 0, 1,  0, rpt0, 0)    // Step  0, Acquire
1937		m088( Local1, 1, 0, 4, 64, rpt0, 0)    // Step  1, Acquire, AE_AML_MUTEX_ORDER
1938		m088( Local0, 1, 0, 4, 64, rpt0, 0)    // Step  2, Acquire, AE_AML_MUTEX_ORDER
1939		m088( lpC0,   1, 0, 4,  0, rpt0, 0)    // Step  3, Acquire
1940		m089( lpC0,   1, 0, 4,  0, rpt0, ord0) // Step  3, Release
1941		m089( lpC0,   1, 0, 1,  0, rpt0, ord0) // Step  0, Release
1942
1943		if (arg1) {
1944		m089( Local0, 1, 0, 4,  0, rpt0, ord0) // Step -1, Release
1945		m089( Local1, 1, 0, 4,  0, rpt0, ord0) // Step -2, Release
1946		}
1947
1948		Decrement(lpN0)
1949		Increment(lpC0)
1950	}
1951
1952	// Check that all mutexes are Released
1953	m08a()
1954
1955	m088( 0, max0, 0, min0,  0, rpt0, 0)    // Step  4, Acquire
1956	m089( 0, max0, 0, min0,  0, rpt0, ord0) // Step  4, Release
1957
1958	// Check that all mutexes are Released
1959	m08a()
1960
1961	/* Restore the value of flag of Global lock */
1962	m078(Local7)
1963}
1964
1965/*
1966 * Check the life after AE_AML_MUTEX_ORDER exception on Release
1967 *
1968 *  1)     Acquire     (N-1)-th level mutex MUX-(N-1)
1969 *  2)     Acquire       (N)-th level mutex MUX-N
1970 *  3) run Release     (N-1)-th level mutex MUX-(N-1) and get AE_AML_MUTEX_ORDER exception
1971 *  4)     Release       (N)-th level mutex MUX-N     and check that no exception on this operation
1972 *  5)     Release     (N-1)-th level mutex MUX-(N-1) and check that no exception on this operation
1973 *  6)     do 1-5 for all N in range 1-15 levels
1974 *  7)     check additionally that all the mutexes are free (run Release and
1975 *         get AE_AML_MUTEX_NOT_ACQUIRED exception for all the mutexes of all levels)
1976 *  8)     Acquire all mutexes of all levels and check that no exceptions
1977 *  9)     Release all mutexes of all levels and check that no exceptions
1978 * 10)     check additionally that all the mutexes are free (see 7)
1979 *
1980 * 11)     do it for GL mode too
1981 *
1982 * arg0 - the value of flag of GL
1983 */
1984Method(m08d, 1, Serialized)
1985{
1986	Name(rpt0, 1)
1987	Name(ord0, 0x0001)
1988
1989	Name(lpN0, 0) // level
1990	Name(lpC0, 0)
1991
1992	/* Set up the value of flag of Global lock */
1993	Store(m078(arg0), Local7)
1994
1995	Subtract(max0, 1, lpN0)
1996	Store(1, lpC0)
1997	While (lpN0) {
1998
1999		Subtract(lpC0, 1, Local0)
2000
2001
2002		m088( Local0,  1, 0, min0,  0, rpt0, 0)    // Step  0, Acquire
2003		m088( lpC0,    1, 0, min0,  0, rpt0, 0)    // Step  1, Acquire
2004
2005		/* Jump over the level */
2006		m089( Local0,  1, 0, min0, 64, rpt0, ord0) // Step  2, Release, AE_AML_MUTEX_ORDER
2007
2008		m089( lpC0,    1, 0, min0,  0, rpt0, ord0) // Step  1, Release
2009		m089( Local0,  1, 0, min0,  0, rpt0, ord0) // Step  0, Release
2010
2011
2012		Decrement(lpN0)
2013		Increment(lpC0)
2014	}
2015
2016	// Check that all mutexes are Released
2017	m08a()
2018
2019	m088( 0, max0, 0, min0,  0, rpt0, 0)    // Step  3, Acquire
2020	m089( 0, max0, 0, min0,  0, rpt0, ord0) // Step  3, Release
2021
2022	// Check that all mutexes are Released
2023	m08a()
2024
2025	/* Restore the value of flag of Global lock */
2026	m078(Local7)
2027}
2028
2029/*
2030 * Check the life after AE_AML_MUTEX_ORDER exception on Release
2031 *
2032 * Similar to the m08d but trying to heal situation by
2033 * Acquiring/Release operations applied to the greater
2034 * level so changing the current level upper than all the
2035 * currently Acquired levels so don't expect exceptions on
2036 * the following Release operations applied in the correct
2037 * inverse order to all the Acquired mutexes.
2038 *
2039 * (for the current 20060828 ACPICA this doesn't help).
2040 */
2041Method(m07f,, Serialized)
2042{
2043	Name(rpt0, 1)
2044	Name(ord0, 0x0001)
2045
2046	Name(lpN0, 0) // level
2047	Name(lpC0, 0)
2048
2049	Subtract(max0, 2, lpN0)
2050	Store(1, lpC0)
2051	While (lpN0) {
2052
2053		Subtract(lpC0, 1, Local0)
2054		Add(lpC0, 1, Local1)
2055
2056
2057		m088( Local0,  1, 0, min0,  0, rpt0, 0)    // Step  0, Acquire
2058		m088( lpC0,    1, 0, min0,  0, rpt0, 0)    // Step  1, Acquire
2059
2060		/* Jump over the level on Releasing */
2061		m089( Local0,  1, 0, min0, 64, rpt0, ord0) // Step  2, Release, AE_AML_MUTEX_ORDER
2062
2063		/*
2064		 * Additional attempt is made to restore the normal calculation -
2065		 * Acquire the mutex M0 of level greater than all the levels
2066		 * touched at that moment so changing the current level by the
2067		 * succeeded operation. Then do Release operations for all
2068		 * the Acquired mutexes in the correct inverse order starting
2069		 * with the M0 mutex expecting no exceptions on them.
2070		 *
2071		 * (for the current 20060828 ACPICA this doesn't help).
2072		 */
2073		m088( lpC0,    1, 0,    1,  0, rpt0, 0)    // Step  3, Acquire
2074		m088( Local1,  1, 0,    1,  0, rpt0, 0)    // Step  4, Acquire
2075		m088( lpC0,    1, 0,    1, 64, rpt0, 0)    // Step  5, Acquire, AE_AML_MUTEX_ORDER
2076		m089( Local1,  1, 0,    1,  0, rpt0, ord0) // Step  4, Release
2077		m089( lpC0,    1, 0,    1,  0, rpt0, ord0) // Step  3, Release
2078
2079		m089( lpC0,    1, 0, min0,  0, rpt0, ord0) // Step  1, Release
2080		m089( Local0,  1, 0, min0,  0, rpt0, ord0) // Step  0, Release
2081
2082
2083		Decrement(lpN0)
2084		Increment(lpC0)
2085	}
2086
2087	// Check that all mutexes are Released
2088	m08a()
2089
2090	m088( 0, max0, 0, min0,  0, rpt0, 0)    // Step  6, Acquire
2091	m089( 0, max0, 0, min0,  0, rpt0, ord0) // Step  6, Release
2092
2093	// Check that all mutexes are Released
2094	m08a()
2095}
2096
2097// ############################################### Run-method:
2098
2099Method(m300)
2100{
2101	if (FL03) {
2102		// Check that all mutexes are Released (doesn't check T804..)
2103		m08a()
2104	}
2105
2106	SRMT("m300")
2107	if (ERR7) {
2108		err("ERRORS were detected during the loading stage", z150, 0x200, 0, 0, 0, ERR7)
2109	}
2110
2111	/* ATTENTION: this test must be run the first */
2112	SRMT("m0b9")
2113	m0b9()
2114
2115
2116	SRMT("m0bb")
2117	m0bb()
2118
2119	SRMT("m301")
2120	m301()
2121
2122	SRMT("m369-0")
2123	m369(0)
2124	SRMT("m369-1")
2125	if (y297) {
2126		m369(1)
2127	} else {
2128		BLCK()
2129	}
2130	SRMT("m369-0")
2131	m369(0)
2132
2133	SRMT("m36a")
2134	m36a()
2135
2136	SRMT("m36b")
2137	m36b()
2138
2139	SRMT("m36c")
2140	m36c()
2141
2142	SRMT("m389")
2143	m389()
2144
2145	SRMT("m07b")
2146	m07b()
2147
2148	SRMT("m38a")
2149	if (y238) {
2150		m38a()
2151	} else {
2152		BLCK()
2153	}
2154
2155	SRMT("m38d")
2156	if (y242) {
2157		m38d()
2158	} else {
2159		BLCK()
2160	}
2161
2162	SRMT("m07d-direct")
2163	if (y242) {
2164		m07d(0x0000)
2165	} else {
2166		BLCK()
2167	}
2168
2169	SRMT("m07d-inverse")
2170	m07d(0x0001)
2171
2172	SRMT("m07a-no-GL")
2173	m07a(0)
2174
2175	SRMT("m07a-GL")
2176	m07a(1)
2177
2178	SRMT("m07e")
2179	m07e()
2180
2181	SRMT("m08b-no-GL-0")
2182	m08b(0, 0)
2183
2184	SRMT("m08b-no-GL-1")
2185	m08b(0, 1)
2186
2187	SRMT("m08b-GL-0")
2188	m08b(1, 0)
2189
2190	SRMT("m08b-GL-1")
2191	m08b(1, 1)
2192
2193	SRMT("m08d-no-GL")
2194	if (y238) {
2195		m08d(0)
2196	} else {
2197		BLCK()
2198	}
2199
2200	SRMT("m08d-GL")
2201	if (y238) {
2202		m08d(1)
2203	} else {
2204		BLCK()
2205	}
2206
2207	SRMT("m07f")
2208	if (y243) {
2209		m07f()
2210	} else {
2211		BLCK()
2212	}
2213
2214	SRMT("m07c")
2215	m07c()
2216
2217	SRMT("m0ba")
2218	m0ba()
2219
2220	/*
2221	 * To see if the mutex-es framework can continue working after AE_LIMIT.
2222	 * Now, after AE_LIMIT, it looks can't actually restore -- many messages
2223	 * during the all further execution of tests, and even the tests
2224	 * "TEST: WAI0, Wait for Events" somewhere hangs forever:
2225	 *
2226	 * **** AcpiExec: Exception AE_LIMIT during execution of method [M369] Opcode [Mutex] @E2
2227	 * ACPI Exception (utmutex-0376): AE_BAD_PARAMETER, Thread 1475 could not acquire Mutex [0] [20074403]
2228	 * ACPI Error (exutils-0180): Could not acquire AML Interpreter mutex [20074403]
2229	 * ACPI Error (utmutex-0421): Mutex [0] is not acquired, cannot release [20074403]
2230	 * ACPI Error (exutils-0250): Could not release AML Interpreter mutex [20074403]
2231	 * **** AcpiExec: Exception override, new status AE_OK
2232	 */
2233	SRMT("m369-0")
2234	m369(0)
2235	SRMT("m369-1")
2236	if (y297) {
2237		m369(1)
2238	} else {
2239		BLCK()
2240	}
2241	SRMT("m369-0")
2242	m369(0)
2243
2244
2245	if (FL03) {
2246		// Check that all mutexes are Released
2247		m08a()
2248	}
2249
2250	CH03("m300", z150, 0x000, 0, 0)
2251}
2252
2253
2254