Debian Codegraph @

tests/aslts/src/runtime/collections/Identity2MS/abbu/recursion/rec_aslts.asl

raw
1 /*
2 * Some or all of this work - Copyright (c) 2006 - 2021, Intel Corp.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
7 *
8 * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * Neither the name of Intel Corporation nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 /*
30 * Tests to check recursive calls of methods for different structure of
31 * sub-trees containing the point from where the call is made and the point
32 * which is just the invoked method, and different relative disposition of
33 * those sub-trees containing the points.
34 */
35
36 Name(z172, 172)
37
38 Name(IG00, 0)
39 Name(IG01, 0)
40 Name(IG02, 0)
41 Name(IG03, 0) // Do anything once only
42
43 Name(RC00, 5)
44 Name(RCFF, 1)
45
46 Name(ts, "mr00")
47
48 Processor(pr00, 0, 0x000, 0x008)
49 {
50 Name(i000, 0xabcd0000)
51 }
52
53 // Initialize sub-test
54 Method(mrfd)
55 {
56 Store(0, IG00)
57 Store(0, IG01)
58 Store(0, IG02)
59 Store(0, IG03)
60 }
61
62 // Printing
63 Method(mrfe, 1)
64 {
65 if (RCFF) {
66 Store(arg0, Debug)
67 }
68 }
69
70 /*
71 * 0-th level method M0 is recursively invoked from
72 * the same M0 method.
73 */
74 Method(mr00)
75 {
76 Store("mr00", ts)
77 mrfe(ts)
78
79 Store(IG00, Local0)
80 Increment(IG00)
81 Increment(IG02)
82 if (LLess(IG00, RC00)) {
83 mr00()
84 }
85
86 Decrement(IG00)
87 if (LNotEqual(Local0, IG00)) {
88 err(ts, z172, __LINE__, 0, 0, Local0, IG00)
89 }
90
91 if (LNotEqual(IG02, RC00)) {
92 if (LNot(IG03)) {
93 Store(1, IG03)
94 err(ts, z172, __LINE__, 0, 0, IG02, RC00)
95 }
96 }
97 }
98
99 /*
100 * 0-th level method M0 invokes recursively 0-th level method M1
101 * which, in its turn, invokes recursively M0
102 * M0 and M1 are respectively the preceding and the following peers each to other
103 */
104 Method(mr01, 1)
105 {
106 Store("mr01", ts)
107
108 mrfe(ts)
109
110 Store(IG00, Local1)
111 Store(arg0, Local2)
112 Increment(IG00)
113 Increment(IG02)
114 if (LLess(IG00, RC00)) {
115 mr02(IG00)
116 }
117
118 Decrement(IG00)
119 if (LNotEqual(Local1, IG00)) {
120 err(ts, z172, __LINE__, 0, 0, Local1, IG00)
121 }
122 if (LNotEqual(Local2, arg0)) {
123 err(ts, z172, __LINE__, 0, 0, Local2, arg0)
124 }
125
126 Multiply(RC00, 2, Local0)
127 Decrement(Local0)
128 if (LNotEqual(IG02, Local0)) {
129 if (LNot(IG03)) {
130 Store(1, IG03)
131 err(ts, z172, __LINE__, 0, 0, IG02, Local0)
132 }
133 }
134 }
135
136 Method(mr02, 1)
137 {
138 Store("mr02", ts)
139
140 mrfe(ts)
141
142 Store(IG01, Local1)
143 Store(arg0, Local2)
144 Increment(IG01)
145 Increment(IG02)
146 if (LLess(IG01, RC00)) {
147 mr01(IG01)
148 }
149
150 Decrement(IG01)
151 if (LNotEqual(Local1, IG01)) {
152 err(ts, z172, __LINE__, 0, 0, Local1, IG01)
153 }
154 if (LNotEqual(Local2, arg0)) {
155 err(ts, z172, __LINE__, 0, 0, Local2, arg0)
156 }
157
158 Multiply(RC00, 2, Local0)
159 Decrement(Local0)
160 if (LNotEqual(IG02, Local0)) {
161 if (LNot(IG03)) {
162 Store(1, IG03)
163 err(ts, z172, __LINE__, 0, 0, IG02, Local0)
164 }
165 }
166 }
167
168 /*
169 * 2-th level method M0 is recursively invoked from
170 * the same M0 method.
171 */
172 Method(mr03,, Serialized)
173 {
174 Store("mr03", ts)
175
176 Device(d100)
177 {
178 Name(i200, 0xabcd0200)
179 Name(i201, 0xabcd0201)
180 }
181
182 Device(d101)
183 {
184 Name(i202, 0xabcd0202)
185 Method(m203)
186 {
187 mrfe("m203")
188
189 Store(IG00, Local0)
190 Increment(IG00)
191 Increment(IG02)
192 if (LLess(IG00, RC00)) {
193 m203()
194 }
195
196 Decrement(IG00)
197 if (LNotEqual(Local0, IG00)) {
198 err(ts, z172, __LINE__, 0, 0, Local0, IG00)
199 }
200
201 }
202 Name(i204, 0xabcd0204)
203 }
204 Device(d102)
205 {
206 Name(i205, 0xabcd0205)
207 Name(i206, 0xabcd0206)
208 }
209
210 d101.m203()
211
212 if (LNotEqual(IG02, RC00)) {
213 if (LNot(IG03)) {
214 Store(1, IG03)
215 err(ts, z172, __LINE__, 0, 0, IG02, RC00)
216 }
217 }
218 }
219
220 /*
221 * 2-th level method M0 invokes recursively 0-th level method M1,
222 * which is not on a path of M0-sub-tree, M1, in its turn, invokes
223 * recursively M0. It is capable because the sub-tree of M0 has been
224 * created at the moment when M1 is invoked.
225 * Note: we can't run M1 in the first turn by that same reason --
226 * sub-tree of M0 would be not created in that case and we fall to
227 * AE_NOT_FOUND exception.
228 */
229 Method(mr04,, Serialized)
230 {
231 Store("mr04", ts)
232
233 Device(d100)
234 {
235 Name(i200, 0xabcd0200)
236 Name(i201, 0xabcd0201)
237 }
238
239 Device(d101)
240 {
241 Name(i202, 0xabcd0202)
242 Method(m203, 1)
243 {
244 mrfe("m203")
245
246 Store(IG00, Local0)
247 Increment(IG00)
248 Increment(IG02)
249 if (LLess(IG00, RC00)) {
250 mr05(IG00)
251 }
252
253 Decrement(IG00)
254 if (LNotEqual(Local0, IG00)) {
255 err(ts, z172, __LINE__, 0, 0, Local0, IG00)
256 }
257
258 }
259 Name(i204, 0xabcd0204)
260 }
261 Device(d102)
262 {
263 Name(i205, 0xabcd0205)
264 Name(i206, 0xabcd0206)
265 }
266
267 d101.m203(0)
268
269 Multiply(RC00, 2, Local0)
270 Decrement(Local0)
271 if (LNotEqual(IG02, Local0)) {
272 if (LNot(IG03)) {
273 Store(1, IG03)
274 err(ts, z172, __LINE__, 0, 0, IG02, Local0)
275 }
276 }
277 }
278
279 Method(mr05, 1)
280 {
281 Store("mr05", ts)
282
283 mrfe(ts)
284
285 Store(IG01, Local1)
286 Store(arg0, Local2)
287 Increment(IG01)
288 Increment(IG02)
289 if (LLess(IG01, RC00)) {
290 ^mr04.d101.m203(IG01)
291 }
292
293 Decrement(IG01)
294 if (LNotEqual(Local1, IG01)) {
295 err(ts, z172, __LINE__, 0, 0, Local1, IG01)
296 }
297 if (LNotEqual(Local2, arg0)) {
298 err(ts, z172, __LINE__, 0, 0, Local2, arg0)
299 }
300
301 Multiply(RC00, 2, Local0)
302 Decrement(Local0)
303 if (LNotEqual(IG02, Local0)) {
304 if (LNot(IG03)) {
305 Store(1, IG03)
306 err(ts, z172, __LINE__, 0, 0, IG02, Local0)
307 }
308 }
309 }
310
311
312 Method(mrff,, Serialized)
313 {
314 Name(ts, "mrff")
315 Name(run0, 1)
316
317 CH03(ts, z172, 0x000, __LINE__, 0)
318
319 SRMT("mr00")
320 mrfd()
321 mr00()
322
323 SRMT("mr01")
324 mrfd()
325 mr01(0)
326
327 SRMT("mr02")
328 mrfd()
329 mr02(0)
330
331 SRMT("mr03")
332 mrfd()
333 mr03()
334
335 SRMT("mr04")
336 mrfd()
337 mr04()
338
339 /*
340 test --- run mr05 and expect exception
341 */
342
343
344 CH03(ts, z172, 0x000, __LINE__, 0)
345 }