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     * Bug 0098:
30     *
31     * SUMMARY: Crash on a specific AML code
32     */
33    Method (ME51, 1, NotSerialized)
34    {
35        Local0 = ObjectType (Arg0)
36        Debug = Local0
37    }
38
39    Method (ME52, 0, Serialized)
40    {
41        Name (RUN0, 0x01)
42        Name (RUN1, 0x01)
43        Name (RUN2, 0x01)
44        Name (P000, Package (0x20)
45        {
46            0x00,
47            DD08,
48            SD01,
49            BD04,
50            0x00
51        })
52        Debug = "============= Test started:"
53        If (RUN0)
54        {
55            Debug = "============= Integer:"
56            Local0 = Local1 = P000 [0x01]
57            Debug = Local1
58            ME51 (Local1)
59            Debug = Local0
60        }
61
62        If (RUN1)
63        {
64            Debug = "============= String:"
65            Local0 = Local1 = P000 [0x02]
66            Debug = Local1
67            ME51 (Local1)
68            Debug = Local0
69        }
70
71        If (RUN2)
72        {
73            Debug = "============= Buffer:"
74            Local0 = Local1 = P000 [0x03]
75            Debug = Local1
76            ME51 (Local1)
77            Debug = Local0
78        }
79
80        Debug = "============= Test finished."
81    }
82
83    /* Arg0 - the type of object */
84    /* (for 8 (- Method) causes crash, Bug 0097) */
85    Method (ME54, 1, Serialized)
86    {
87        Name (PD02, Package (0x20)
88        {
89            0x00,
90            ID0C,
91            SD02,
92            BD05,
93            PD02,
94            FD02,
95            DD09,
96            ED01,
97            ME53,
98            MXD1,
99            RD03,
100            PWD0,
101            PRD0,
102            TZD0,
103            BFD0
104        })
105        Debug = "============= Test started:"
106        Switch (ToInteger (Arg0))
107        {
108            Case (0x00)
109            {
110                Debug = "============= Uninitialized:"
111            }
112            Case (0x01)
113            {
114                Debug = "============= Integer:"
115                Local0 = Local1 = PD02 [0x01]
116                Debug = Local1
117                ME56 (Local1)
118                Debug = Local0
119            }
120            Case (0x02)
121            {
122                Debug = "============= String:"
123                Local0 = Local1 = PD02 [0x02]
124                Debug = Local1
125                ME56 (Local1)
126                Debug = Local0
127            }
128            Case (0x03)
129            {
130                Debug = "============= Buffer:"
131                Local0 = Local1 = PD02 [0x03]
132                Debug = Local1
133                ME56 (Local1)
134                Debug = Local0
135            }
136            Case (0x04)
137            {
138                Debug = "============= Package:"
139                Local0 = Local1 = PD02 [0x04]
140                Debug = Local1
141                ME56 (Local1)
142                Debug = Local0
143            }
144            Case (0x05)
145            {
146                Debug = "============= Field Unit:"
147                Local0 = Local1 = PD02 [0x05]
148                Debug = Local1
149                ME56 (Local1)
150                Debug = Local0
151            }
152            Case (0x06)
153            {
154                Debug = "============= Device:"
155                Local0 = Local1 = PD02 [0x06]
156                Debug = Local1
157                ME56 (Local1)
158                Debug = Local0
159            }
160            Case (0x07)
161            {
162                Debug = "============= Event:"
163                Local0 = Local1 = PD02 [0x07]
164                Debug = Local1
165                ME56 (Local1)
166                Debug = Local0
167            }
168            Case (0x08)
169            {
170                Debug = "============= Method:"
171                Local0 = Local1 = PD02 [0x08]
172                Debug = Local1
173                ME56 (Local1)
174                Debug = Local0
175            }
176            Case (0x09)
177            {
178                Debug = "============= Mutex:"
179                Local0 = Local1 = PD02 [0x09]
180                Debug = Local1
181                ME56 (Local1)
182                Debug = Local0
183            }
184            Case (0x0A)
185            {
186                Debug = "============= OperationRegion:"
187                Local0 = Local1 = PD02 [0x0A]
188                Debug = Local1
189                ME56 (Local1)
190                Debug = Local0
191            }
192            Case (0x0B)
193            {
194                Debug = "============= PowerResource:"
195                Local0 = Local1 = PD02 [0x0B]
196                Debug = Local1
197                ME56 (Local1)
198                Debug = Local0
199            }
200            Case (0x0C)
201            {
202                Debug = "============= Processor:"
203                Local0 = Local1 = PD02 [0x0C]
204                Debug = Local1
205                ME56 (Local1)
206                Debug = Local0
207            }
208            Case (0x0D)
209            {
210                Debug = "============= ThermalZone:"
211                Local0 = Local1 = PD02 [0x0D]
212                Debug = Local1
213                ME56 (Local1)
214                Debug = Local0
215            }
216            Case (0x0E)
217            {
218                Debug = "============= Buffer Field:"
219                Local0 = Local1 = PD02 [0x0E]
220                Debug = Local1
221                ME56 (Local1)
222                Debug = Local0
223            }
224
225        } /* Switch */
226
227        Debug = "============= Test finished."
228    }
229
230    /*
231     * The same as me54 but all the cases are invoked not
232     * one by one calling to the me54() Method with the next
233     * in turn type of data but all the types of data are
234     * exercised simultaneously  during one call to me55
235     * method.
236     */
237    Method (ME55, 0, Serialized)
238    {
239        Name (PD02, Package (0x20)
240        {
241            0x00,
242            ID0C,
243            SD02,
244            BD05,
245            PD02,
246            FD02,
247            DD09,
248            ED01,
249            ME53,
250            MXD1,
251            RD03,
252            PWD0,
253            PRD0,
254            TZD0,
255            BFD0
256        })
257        Debug = "============= Test started:"
258        /*	Switch (Arg0) { */
259        /*	Case (0) { */
260        Debug = "============= Uninitialized:"
261        /*	} */
262        /*	Case (1) { */
263        Debug = "============= Integer:"
264        Local0 = Local1 = PD02 [0x01]
265        Debug = Local1
266        ME56 (Local1)
267        Debug = Local0
268        /*	} */
269        /*	Case (2) { */
270        Debug = "============= String:"
271        Local0 = Local1 = PD02 [0x02]
272        Debug = Local1
273        ME56 (Local1)
274        Debug = Local0
275        /*	} */
276        /*	Case (3) { */
277        Debug = "============= Buffer:"
278        Local0 = Local1 = PD02 [0x03]
279        Debug = Local1
280        ME56 (Local1)
281        Debug = Local0
282        /*	} */
283        /*	Case (4) { */
284        Debug = "============= Package:"
285        Local0 = Local1 = PD02 [0x04]
286        Debug = Local1
287        ME56 (Local1)
288        Debug = Local0
289        /*	} */
290        /*	Case (5) { */
291        Debug = "============= Field Unit:"
292        Local0 = Local1 = PD02 [0x05]
293        Debug = Local1
294        ME56 (Local1)
295        Debug = Local0
296        /*	} */
297        /*	Case (6) { */
298        Debug = "============= Device:"
299        Local0 = Local1 = PD02 [0x06]
300        Debug = Local1
301        ME56 (Local1)
302        Debug = Local0
303        /*	} */
304        /*	Case (7) { */
305        Debug = "============= Event:"
306        Local0 = Local1 = PD02 [0x07]
307        Debug = Local1
308        ME56 (Local1)
309        Debug = Local0
310        /*	} */
311        /*
312         * Causes crash, Bug 0097
313         *
314         *	//	Case (8) {
315         *			Store("============= Method:", Debug)
316         *			Store(Index(pd02, 8, Local1), Local0)
317         *			Store(Local1, Debug)
318         *			me56(Local1)
319         *			Store(Local0, Debug)
320         *	//	}
321         */
322        /*	Case (9) { */
323        Debug = "============= Mutex:"
324        Local0 = Local1 = PD02 [0x09]
325        Debug = Local1
326        ME56 (Local1)
327        Debug = Local0
328        /*	} */
329        /*	Case (10) { */
330        Debug = "============= OperationRegion:"
331        Local0 = Local1 = PD02 [0x0A]
332        Debug = Local1
333        ME56 (Local1)
334        Debug = Local0
335        /*	} */
336        /*	Case (11) { */
337        Debug = "============= PowerResource:"
338        Local0 = Local1 = PD02 [0x0B]
339        Debug = Local1
340        ME56 (Local1)
341        Debug = Local0
342        /*	} */
343        /*	Case (12) { */
344        Debug = "============= Processor:"
345        Local0 = Local1 = PD02 [0x0C]
346        Debug = Local1
347        ME56 (Local1)
348        Debug = Local0
349        /*	} */
350        /*	Case (13) { */
351        Debug = "============= ThermalZone:"
352        Local0 = Local1 = PD02 [0x0D]
353        Debug = Local1
354        ME56 (Local1)
355        Debug = Local0
356        /*	} */
357        /*	Case (14) { */
358        Debug = "============= Buffer Field:"
359        Local0 = Local1 = PD02 [0x0E]
360        Debug = Local1
361        ME56 (Local1)
362        Debug = Local0
363        /*	} */
364        /*	} // Switch */
365        Debug = "============= Test finished."
366    }
367
368    Method (ME56, 1, NotSerialized)
369    {
370        Local0 = ObjectType (Arg0)
371        Debug = Local0
372    }
373
374    Method (ME57, 0, NotSerialized)
375    {
376        ME54 (0x00)
377        ME54 (0x01)
378        ME54 (0x02)
379        ME54 (0x03)
380        ME54 (0x04)
381        ME54 (0x05)
382        ME54 (0x06)
383        ME54 (0x07)
384        /*
385         * Causes crash, Bug 0097
386         *		me54(8)
387         */
388        ME54 (0x09)
389        ME54 (0x0A)
390        ME54 (0x0B)
391        ME54 (0x0C)
392        ME54 (0x0D)
393        ME54 (0x0E)
394    }
395
396    Method (ME58, 0, NotSerialized)
397    {
398        /*
399         * Exercise one particular type of data
400         * which is specified by Arg0.
401         *
402         * Arg0 - the type of object (0-14)
403         * for 8 (Method) causes crash, Bug 0097
404         */
405        ME54 (0x0E)
406        /*
407         * Call to me54 for each type of data excluding
408         * 8 (Method) (causes crash, Bug 0097).
409         */
410        ME57 ()
411        /*
412         * The same as me54 but all the cases are invoked not
413         * one by one calling to the me54() Method with the next
414         * in turn type of data but all the types of data are
415         * exercised simultaneously  during one call to me55
416         * method.
417         */
418        ME55 ()
419    }
420