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 304:
30     *
31     * SUMMARY: No exception AE_AML_METHOD_LIMIT for the number of method invocations exceeding 255
32     */
33    Method (M1ED, 0, NotSerialized)
34    {
35        Method (M18A, 1, Serialized, 3)
36        {
37            Name (RPT0, 0x00)
38            Name (I000, 0x00)
39            /*
40             * Total number of calls of the same Recursively Called method (RCM),
41             * the first call is counted there too.
42             */
43            Name (N000, 0x03)
44            Name (CNT0, 0x00) /* how many methods are in progress simultaneously */
45            Name (MAX0, 0x00) /* maximal number of methods being in progress simultaneously */
46            Name (CNT1, 0x00) /* summary of total indexes */
47            Name (IX00, 0x00) /* total index of current call */
48            Name (IND1, 0x00) /* index of call to m100 */
49            Name (IND2, 0x00) /* index of call to m200 */
50            Name (IND3, 0x00) /* index of call to m300 */
51            Name (IND4, 0x00) /* index of call to m400 */
52            Name (N100, 0x03) /* number of calls to m100 */
53            Name (N200, 0x06) /* number of calls to m200 */
54            Name (N300, 0x0C) /* number of calls to m300 */
55            Name (N400, 0x18) /* number of calls to m400 */
56            Name (P100, Package (N100){}) /* Package to keep total indexes of call to m100 */
57            Name (P200, Package (N200){}) /* Package to keep total indexes of call to m200 */
58            Name (P300, Package (N300){}) /* Package to keep total indexes of call to m300 */
59            Name (P400, Package (0x0100){}) /* Package to keep total indexes of call to m400 */
60            /* Benchmarks of indexes */
61
62            Name (B1B0, Buffer (N100)
63            {
64                 0x00, 0x16, 0x2C                                 // ..,
65            })
66            Name (B2B0, Buffer (N200)
67            {
68                 0x01, 0x0B, 0x15, 0x17, 0x21, 0x2B               // ....!+
69            })
70            Name (B3B0, Buffer (N300)
71            {
72                /* 0000 */  0x02, 0x06, 0x0A, 0x0C, 0x10, 0x14, 0x18, 0x1C,  // ........
73                /* 0008 */  0x20, 0x22, 0x26, 0x2A                           //  "&*
74            })
75            Name (B4B0, Buffer (0x0100)
76            {
77                /* 0000 */  0x03, 0x04, 0x05, 0x07, 0x08, 0x09, 0x0D, 0x0E,  // ........
78                /* 0008 */  0x0F, 0x11, 0x12, 0x13, 0x19, 0x1A, 0x1B, 0x1D,  // ........
79                /* 0010 */  0x1E, 0x1F, 0x23, 0x24, 0x25, 0x27, 0x28, 0x29   // ..#$%'()
80            })
81            /*
82             * Open method execution
83             *
84             * arg0 - ID of method (1,2,3...)
85             * arg1 - the message to be reported
86             */
87            Method (M800, 2, Serialized)
88            {
89                If (RPT0)
90                {
91                    Debug = Arg1
92                }
93
94                CNT0++
95                If ((CNT0 > MAX0))
96                {
97                    MAX0 = CNT0 /* \M1ED.M18A.CNT0 */
98                }
99
100                Switch (ToInteger (Arg0))
101                {
102                    Case (0x01)
103                    {
104                        P100 [IND1] = IX00 /* \M1ED.M18A.IX00 */
105                        IND1++
106                    }
107                    Case (0x02)
108                    {
109                        P200 [IND2] = IX00 /* \M1ED.M18A.IX00 */
110                        IND2++
111                    }
112                    Case (0x03)
113                    {
114                        P300 [IND3] = IX00 /* \M1ED.M18A.IX00 */
115                        IND3++
116                    }
117                    Case (0x04)
118                    {
119                        P400 [IND4] = IX00 /* \M1ED.M18A.IX00 */
120                        IND4++
121                    }
122
123                }
124
125                IX00++ /* total index */
126            }
127
128            /*
129             * Close method execution
130             *
131             * arg0 - ID of method (1,2,3...)
132             */
133            Method (M801, 1, NotSerialized)
134            {
135                CNT0--
136            }
137
138            /*
139             * arg0 - ID of method (1,2,3...)
140             * arg1 - number of elements to be compared
141             * arg2 - Package
142             * arg3 - Package with the benchmark values
143             */
144            Method (M802, 4, Serialized)
145            {
146                Name (LPN0, 0x00)
147                Name (LPC0, 0x00)
148                LPN0 = Arg1
149                LPC0 = 0x00
150                While (LPN0)
151                {
152                    Local0 = DerefOf (Arg2 [LPC0])
153                    Local1 = DerefOf (Arg3 [LPC0])
154                    If ((Local0 != Local1))
155                    {
156                        ERR (__METHOD__, ZFFF, __LINE__, 0x00, 0x00, Local0, Local1)
157                        Debug = Arg0
158                        Debug = LPC0 /* \M1ED.M18A.M802.LPC0 */
159                    }
160
161                    LPN0--
162                    LPC0++
163                }
164
165                Switch (ToInteger (Arg0))
166                {
167                    Case (0x01)
168                    {
169                        If ((IND1 != N100))
170                        {
171                            ERR (__METHOD__, ZFFF, __LINE__, 0x00, 0x00, IND1, N100)
172                        }
173                    }
174                    Case (0x02)
175                    {
176                        If ((IND2 != N200))
177                        {
178                            ERR (__METHOD__, ZFFF, __LINE__, 0x00, 0x00, IND2, N200)
179                        }
180                    }
181                    Case (0x03)
182                    {
183                        If ((IND3 != N300))
184                        {
185                            ERR (__METHOD__, ZFFF, __LINE__, 0x00, 0x00, IND3, N300)
186                        }
187                    }
188                    Case (0x04)
189                    {
190                        If ((IND4 != N400))
191                        {
192                            ERR (__METHOD__, ZFFF, __LINE__, 0x00, 0x00, IND4, N400)
193                        }
194                    }
195
196                }
197            }
198
199            /*
200             * Arguments of methods:
201             * arg0 - 0 - the first call, otherwise - recursive calls
202             */
203            Name (C000, 0x03)
204            Name (C100, 0x03)
205            Name (C200, 0x03)
206            Name (C300, 0x03)
207            /*
208             * None internal objects (including Methods) or Switches in Serialized methods below
209             *
210             * Note: if Serialized method has internal objects (including Methods and Switches)
211             *       it could not be invoked recursively by the same thread.
212             */
213            Method (M100, 0, Serialized)
214            {
215                C100 = 0x03
216                Local1 = IND1 /* \M1ED.M18A.IND1 */
217                Local0 = IX00 /* \M1ED.M18A.IX00 */
218                M800 (0x01, "m100")
219                C000--
220                If ((C000 == 0x00)){                /* m000() */
221                }
222                Else
223                {
224                    M200 ()
225                }
226
227                M801 (0x01)
228                CNT1 += Local0
229                Local1 = DerefOf (P100 [Local1])
230                If ((Local1 != Local0))
231                {
232                    ERR (__METHOD__, ZFFF, __LINE__, 0x00, 0x00, Local1, Local0)
233                }
234            }
235
236            Method (M200, 0, Serialized)
237            {
238                C200 = 0x03
239                Local1 = IND2 /* \M1ED.M18A.IND2 */
240                Local0 = IX00 /* \M1ED.M18A.IX00 */
241                M800 (0x02, "m200")
242                C100--
243                If ((C100 == 0x00))
244                {
245                    M100 ()
246                }
247                Else
248                {
249                    M300 ()
250                }
251
252                M801 (0x02)
253                CNT1 += Local0
254                Local1 = DerefOf (P200 [Local1])
255                If ((Local1 != Local0))
256                {
257                    ERR (__METHOD__, ZFFF, __LINE__, 0x00, 0x00, Local1, Local0)
258                }
259            }
260
261            Method (M300, 0, Serialized)
262            {
263                If (I000)
264                {
265                    C300 = 0x1F
266                                /* Store(32, c300) // AE_AML_METHOD_LIMIT occurs for this number (0x111 == 273) */
267                }
268                Else
269                {
270                    C300 = 0x03
271                }
272
273                Local1 = IND3 /* \M1ED.M18A.IND3 */
274                Local0 = IX00 /* \M1ED.M18A.IX00 */
275                M800 (0x03, "m300")
276                C200--
277                If ((C200 == 0x00))
278                {
279                    M200 ()
280                }
281                Else
282                {
283                    M400 ()
284                }
285
286                M801 (0x03)
287                CNT1 += Local0
288                Local1 = DerefOf (P300 [Local1])
289                If ((Local1 != Local0))
290                {
291                    ERR (__METHOD__, ZFFF, __LINE__, 0x00, 0x00, Local1, Local0)
292                }
293            }
294
295            Method (M400, 0, Serialized)
296            {
297                Local1 = IND4 /* \M1ED.M18A.IND4 */
298                Local0 = IX00 /* \M1ED.M18A.IX00 */
299                M800 (0x04, "m400")
300                C300--
301                If ((C300 == 0x00))
302                {
303                    M300 ()
304                }
305                Else
306                {
307                    M400 ()
308                }
309
310                M801 (0x04)
311                CNT1 += Local0
312                Local1 = DerefOf (P400 [Local1])
313                If ((Local1 != Local0))
314                {
315                    ERR (__METHOD__, ZFFF, __LINE__, 0x00, 0x00, Local1, Local0)
316                }
317            }
318
319            I000 = Arg0
320            M100 ()
321            Concatenate ("Maximal number of methods being in progress simultaneously ", MAX0, Debug)
322            /* Check if exception takes place (AE_AML_METHOD_LIMIT) */
323
324            If (Arg0)
325            {
326                CH04 (__METHOD__, 0x00, 0x54, 0x00, __LINE__, 0x00, 0x00) /* AE_AML_METHOD_LIMIT */
327            }
328            Else
329            {
330                CH03 (__METHOD__, 0x00, __LINE__, 0x00, 0x00)
331            }
332        }
333
334        CH03 (__METHOD__, 0x00, __LINE__, 0x00, 0x00)
335        SRMT ("m18a-0")
336        M18A (0x00)
337        CH03 (__METHOD__, 0x00, __LINE__, 0x00, 0x00)
338        SRMT ("m18a-1")
339        M18A (0x01)
340        CH03 (__METHOD__, 0x00, __LINE__, 0x00, 0x00)
341    }
342