Debian Codegraph @

tests/aslts/src/runtime/collections/bdemo/ACPICA/0073_ASL/misc.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 // Miscellaneous not systematized tests
30
31 Name(z054, 54)
32
33 // Looks like Default is at all not implemented
34
35 Method(mZ00, 1)
36 {
37 Store(0, Local0)
38 Store(0, Local1)
39
40 // Bug XXX. This Switch code below causes ASL-compiler to fail
41 // for full.asl file with the diagnostics like this:
42 // nssearch-0397: *** Error: NsSearchAndEnter:
43 // Bad character in ACPI Name: 5B5F545F
44 // and fall into recursion:
45 // Remark 3040 - Recursive method call ^ (ERR_)
46 // Note: (0x5B5F545F is equal to "[_T_")
47
48 Switch (Local1) {
49 Case (5) {
50 Store(5, Local0)
51 }
52 Default {
53 Store(1, Local0)
54 }
55 }
56
57 if (LNotEqual(Local0, 1)) {
58 err(arg0, z054, __LINE__, 0, 0, Local0, 0)
59 }
60 }
61
62 // Concatenate operator affects the object passed as Source2 parameter
63
64 Method(mZ01, 1) {
65 Concatenate("qwertyuiop", arg0)
66 }
67
68 Method(mZ02, 1)
69 {
70 Store(0, Local0)
71 mZ01(Local0)
72 if (LNotequal(Local0, 0)) {
73 err(arg0, z054, __LINE__, 0, 0, Local0, 0)
74 }
75
76 Store(0, Local0)
77 Concatenate("qwertyuiop", Local0)
78 if (LNotequal(Local0, 0)) {
79 err(arg0, z054, __LINE__, 0, 0, Local0, 0)
80 }
81 }
82
83 // Unexpected value returned by ObjectType for Field Unit objects
84
85 // The field passed as explicit reference (RefOf)
86 Method(mZ05, 1)
87 {
88 OperationRegion(r000, SystemMemory, 0x100, 0x100)
89 Field (r000, ByteAcc, NoLock, Preserve) {
90 f000, 32
91 }
92
93 Store(ObjectType(RefOf(f000)), Local0)
94 if (LNotEqual(Local0, 5)) {
95 err(arg0, z054, __LINE__, 0, 0, Local0, 0)
96 }
97 }
98
99 // The BankField corrupts the contents of OperationRegion
100
101 Method(mZ06, 1)
102 {
103 OperationRegion(r000, SystemMemory, 0x100, 0x100)
104 Field (r000, ByteAcc, NoLock, Preserve) {
105 bnk0, 8
106 }
107
108 BankField (r000, bnk0, 0, ByteAcc, NoLock, Preserve) {
109 Offset(16),
110 bf00, 8,
111 }
112
113 BankField (r000, bnk0, 1, ByteAcc, NoLock, Preserve) {
114 Offset(17),
115 bf01, 8,
116 }
117
118 Store(1, bnk0)
119 if (LNotEqual(bnk0, 1)) {
120 err(arg0, z054, __LINE__, 0, 0, bnk0, 0)
121 }
122
123 Store(0x96, bf01)
124 if (LNotEqual(bnk0, 1)) {
125 err(arg0, z054, __LINE__, 0, 0, bnk0, 0)
126 }
127
128 Store(0x87, bf00)
129 if (LNotEqual(bnk0, 1)) {
130 err(arg0, z054, __LINE__, 0, 0, bnk0, 0)
131 }
132
133 if (LNotEqual(bf00, 0x87)) {
134 err(arg0, z054, __LINE__, 0, 0, bf00, 0)
135 }
136
137 if (LNotEqual(bf01, 0x96)) {
138 err(arg0, z054, __LINE__, 0, 0, bf01, 0)
139 }
140 }
141
142 // ToBuffer caused destroying of source buffer passed by Data parameter
143 Method(mZ07, 1)
144 {
145 Store(Buffer(4){10, 11, 12, 13}, Local0)
146 Store(ObjectType(Local0), Local1)
147
148 if (LNotEqual(Local1, c00b)) {
149 err(arg0, z054, __LINE__, 0, 0, Local1, 0)
150 }
151
152 ToBuffer(Local0, Local2)
153
154 Store(0xaa, Local3)
155
156 Store(ObjectType(Local0), Local3)
157
158 if (LNotEqual(Local3, c00b)) {
159 err(arg0, z054, __LINE__, 0, 0, Local3, 0)
160 }
161 }
162
163 // ObjectType() operator should be allowed to deal with the
164 // uninitialized objects.
165
166 // Uncomment this when the problem will be fixed and compile
167 // will not fail in this case like it do now: "Method local
168 // variable is not initialized (Local0)".
169 Method(mZ08, 1)
170 {
171 Store(ObjectType(Local0), Local1)
172 }
173
174 // Now, this cause exception but should not
175 Method(mZ09, 2)
176 {
177 if (arg1) {
178 Store(0, Local0)
179 }
180
181 CH03("", 0, 0, __LINE__, 0)
182
183 Store(ObjectType(Local0), Local1)
184
185 if (LNotEqual(Local1, 0)) {
186 err(arg0, z054, __LINE__, 0, 0, Local1, 0)
187 }
188
189 CH03("", 0, 0, __LINE__, 0)
190 }
191
192 Method(mZ0a, 1)
193 {
194 mZ09(arg0, 0)
195 }
196
197 // DerefOf. If the Source evaluates to a string, the string is evaluated
198 // as an ASL name (relative to the current scope) and the contents of that
199 // object are returned.
200 Method(mZ0b, 1)
201 {
202 Name(b000, Buffer(){ 1, 2, 3, 4, 5, 6, 7, 8 })
203
204 Store("b000", Local0)
205
206 Store("================ 0:", Debug)
207
208 Store(DerefOf(Local0), Local1)
209
210 Store("================ 1:", Debug)
211
212 Store(ObjectType(Local1), Local2)
213
214 if (LNotEqual(Local2, 3)) {
215 err(arg0, z054, __LINE__, 0, 0, Local2, 0)
216 }
217
218 Store("================ 2:", Debug)
219
220 Store(Local1, Debug)
221 Store(Local2, Debug)
222
223 return (0)
224 }
225
226 /*
227 // Currently, incorrect test
228 // The size of Strings in Package is determined incorrectly
229 Method(mZ0c, 1)
230 {
231 Name(p000, Package() {
232 "012",
233 "0123456789abcdef",
234 Buffer() {17,28,69,11,22,34,35,56,67,11},
235 "012345",
236 })
237
238 Store(DeRefOf(Index(p000, 1)), Local0)
239 Store(0, Index(Local0, 5))
240
241 Store(0, Index(p000, 1))
242
243 Store(DeRefOf(Index(p000, 1)), Local0)
244 // Store(0, Index(Local0, 5))
245
246 Store("=================:", Debug)
247 Store(Local0, Debug)
248
249 // 0
250 Store(DeRefOf(Index(p000, 0)), Local2)
251 Store(SizeOf(Local2), Local3)
252
253 Store(Local3, Debug)
254
255 if (LNotEqual(Local3, 3)) {
256 err(arg0, z054, __LINE__, 0, 0, Local3, 3)
257 }
258
259 // 1
260 Store(DeRefOf(Index(p000, 1)), Local2)
261 Store(SizeOf(Local2), Local3)
262
263 Store(Local3, Debug)
264
265 if (LNotEqual(Local3, 9)) {
266 err(arg0, z054, __LINE__, 0, 0, Local3, 9)
267 }
268
269 // 2
270 Store(DeRefOf(Index(p000, 2)), Local2)
271 Store(SizeOf(Local2), Local3)
272
273 Store(Local3, Debug)
274
275 if (LNotEqual(Local3, 6)) {
276 err(arg0, z054, __LINE__, 0, 0, Local3, 6)
277 }
278
279 Store(SizeOf(p000), Local0)
280
281 Store(Local0, Debug)
282
283 if (LNotEqual(Local0, 3)) {
284 err(arg0, z054, __LINE__, 0, 0, Local0, 3)
285 }
286 }
287 */
288
289 /*
290 // ATTENTION: such type tests have to be added and extended
291 Method(mZ0d, 1)
292 {
293 Name(p000, Package() {
294 0x12345678, 0x90abcdef,
295 })
296 Name(b000, Buffer() {0x78,0x56,0x34,0x12, 0xef,0xcd,0xab,0x90})
297
298 Store(DeRefOf(Index(p000, 0)), Local7)
299
300 if (LEqual(b000, Local7)) {
301 err(arg0, z054, __LINE__, 0, 0, b000, Local7)
302 }
303
304 if (LEqual(Local7, b000)) {
305 err(arg0, z054, __LINE__, 0, 0, Local7, b000)
306 }
307
308 return (0)
309 }
310 */
311
312
313 // Bug 54: All the ASL Operators which deal with at least two Buffer type
314 // objects cause unexpected exceptions in cases when both Buffer type objects
315 // are passed immediately
316 Method(mZ0e, 1)
317 {
318 CH03("", 0, 0, __LINE__, 0)
319
320 Add( Buffer() {0x79}, Buffer() {0x79} )
321
322 CH03("", 0, 0, __LINE__, 0)
323 }
324
325 // Bug 57: The empty Return operator (without specifying the returning value)
326 // is processed incorrectly
327 Method(mZ0f, 1) {
328
329 Method(mZ10, 2) {
330
331 if (arg1) {
332 return (0x1234)
333
334 // ASL-compiler report Warning in this case
335 // Store("ERROR 0: mZ13, after Return !!!", Debug)
336 }
337 err(arg0, z054, __LINE__, 0, 0, 0, 0)
338
339 return (0x5678)
340 }
341
342 Method(mZ11, 2) {
343
344 if (arg1) {
345
346 return
347
348 // ASL-compiler DOESN'T report Warning in this case!!!
349 // And the Store operator below is actually processed!!!
350
351 err(arg0, z054, __LINE__, 0, 0, 0, 0)
352 }
353
354 err(arg0, z054, __LINE__, 0, 0, 0, 0)
355
356 return
357 }
358
359 Store(mZ10(arg0, 1), Local7)
360
361 mZ11(arg0, 1)
362
363 return (0)
364 }
365
366 // Bug 59: The String to Buffer Rule from the Table 17-8 "Object Conversion
367 // Rules" says "If the string is shorter than the buffer, the buffer size is
368 // reduced".
369 Method(mZ10, 1) {
370 Name(str0, "\x01\x02")
371 Name(buf0, Buffer(){0x03, 0x04, 0x05})
372
373 Store(str0, buf0)
374
375 if (LNotEqual(Sizeof(buf0), 2)) {
376 // Error: length of the buffer not reduced to the stored string
377 err(arg0, z054, __LINE__, 0, 0, 0, 0)
378 }
379 return (0)
380 }
381
382 // Bug 65: The Buffer Field type objects should be passed
383 // to Methods without any conversion, but instead
384 // they are converted to Buffers or Integers depending
385 // on the size of the Buffer Field object and the
386 // run mode (32-bit or 64/bit mode).
387 Method(mZ11, 1) {
388 Name(b000, Buffer(200) {})
389 CreateField(b000, 0, 8, bf00)
390
391 Method(m000, 2)
392 {
393 Store(ObjectType(arg1), Local0)
394 if (LNotEqual(Local0, 14)) {
395 err(arg0, z054, __LINE__, 0, 0, Local0, 14)
396 }
397 }
398
399 Method(m001, 1)
400 {
401 Store(ObjectType(bf00), Local0)
402 if (LNotEqual(Local0, 14)) {
403 err(arg0, z054, __LINE__, 0, 0, Local0, 14)
404 } else {
405 m000(arg0, bf00)
406 }
407 }
408
409 m001(arg0)
410 }
411
412 // Bug 66: The Field Unit type objects should be passed
413 // to Methods without any conversion, but instead
414 // they are converted to Buffers or Integers depending
415 // on the size of the Buffer Field object and the
416 // run mode (32-bit or 64/bit mode).
417 Method(mZ12, 1) {
418 OperationRegion(r000, SystemMemory, 0x100, 0x100)
419 Field(r000, ByteAcc, NoLock, Preserve) { f000, 8 }
420
421 Method(m000, 2)
422 {
423 Store(ObjectType(arg1), Local0)
424 if (LNotEqual(Local0, 5)) {
425 err(arg0, z054, __LINE__, 0, 0, Local0, 5)
426 }
427 }
428
429 Method(m001, 1)
430 {
431 Store(ObjectType(f000), Local0)
432 if (LNotEqual(Local0, 5)) {
433 err(arg0, z054, __LINE__, 0, 0, Local0, 5)
434 } else {
435 m000(arg0, f000)
436 }
437 }
438
439 m001(arg0)
440 }
441
442 // Bug 67: The Buffer Field type objects should be RETURNED
443 // by Methods without any conversion, but instead
444 // they are converted to Buffers or Integers depending
445 // on the size of the Buffer Field object and the
446 // run mode (32-bit or 64/bit mode).
447 Method(mZ13, 1) {
448 Name(b000, Buffer(200) {})
449 CreateField(b000, 0, 8, bf00)
450
451 Method(m000)
452 {
453 return (bf00)
454 }
455
456 Method(m001, 1)
457 {
458 Store(ObjectType(bf00), Local0)
459 if (LNotEqual(Local0, 14)) {
460 err(arg0, z054, __LINE__, 0, 0, Local0, 14)
461 } else {
462 Store(m000(), Local7)
463 Store(ObjectType(Local7), Local0)
464 if (LNotEqual(Local0, 14)) {
465 err(arg0, z054, __LINE__, 0, 0, Local0, 14)
466 }
467 }
468 }
469
470 m001(arg0)
471 }
472
473 // Bug 68: The Field Unit type objects should be RETURNED
474 // by Methods without any conversion, but instead
475 // they are converted to Buffers or Integers depending
476 // on the size of the Buffer Field object and the
477 // run mode (32-bit or 64/bit mode).
478 Method(mZ14, 1) {
479 OperationRegion(r000, SystemMemory, 0x100, 0x100)
480 Field(r000, ByteAcc, NoLock, Preserve) { f000, 8 }
481
482 Method(m000)
483 {
484 return (f000)
485 }
486
487 Method(m001, 1)
488 {
489 Store(ObjectType(f000), Local0)
490 if (LNotEqual(Local0, 5)) {
491 err(arg0, z054, __LINE__, 0, 0, Local0, 5)
492 } else {
493 Store(m000(), Local7)
494 Store(ObjectType(Local7), Local0)
495 if (LNotEqual(Local0, 5)) {
496 err(arg0, z054, __LINE__, 0, 0, Local0, 5)
497 }
498 }
499 }
500
501 m001(arg0)
502 }
503
504 // Bug 30. This test may be removed there after
505 // the Field relative tests will be implemented.
506 // Caused crash.
507 Method(mZ15, 1)
508 {
509 Method(m000)
510 {
511 // Field Unit
512 OperationRegion(r000, SystemMemory, 0x100, 0x100)
513 Field(r000, ByteAcc, NoLock, Preserve) {
514 f000, 8,
515 f001, 16,
516 f002, 32,
517 f003, 33,
518 f004, 1,
519 f005, 64,
520 }
521
522 Store("------------ Fields:", Debug)
523 Store(f000, Debug)
524 Store(f001, Debug)
525 Store(f002, Debug)
526 Store(f003, Debug)
527 Store(f004, Debug)
528 Store(f005, Debug)
529 Store("------------.", Debug)
530
531 return (0)
532 }
533
534 Method(m001)
535 {
536 // Field Unit
537 OperationRegion(r000, SystemMemory, 0x100, 0x100)
538 Field(r000, ByteAcc, NoLock, Preserve) {
539 f000, 8,
540 f001, 16,
541 f002, 32,
542 f003, 33,
543 f004, 7,
544 f005, 64,
545 }
546
547 Store("------------ Fields:", Debug)
548 Store(f000, Debug)
549 Store(f001, Debug)
550 Store(f002, Debug)
551 Store(f003, Debug)
552 Store(f004, Debug)
553 Store(f005, Debug)
554 Store("------------.", Debug)
555
556 return (0)
557 }
558
559 m000()
560 m001()
561 return (0)
562 }
563
564 Method(mZ16, 1)
565 {
566 Method(m000)
567 {
568 return (0x12345678)
569 }
570
571 Method(m001, 1)
572 {
573 return (0x12345678)
574 }
575
576 Store(ObjectType(m000), Local0)
577 if (LNotEqual(Local0, c010)) {
578 err(arg0, z054, __LINE__, 0, 0, Local0, c010)
579 }
580
581 /* Nov. 2012: Method invocation as arg to ObjectType is now illegal */
582 //
583 // Store(ObjectType(m000()), Local0)
584 // if (LNotEqual(Local0, c009)) {
585 // err(arg0, z054, __LINE__, 0, 0, Local0, c009)
586 // }
587 //
588 // Store(ObjectType(m001(123)), Local1)
589 // if (LNotEqual(Local1, c009)) {
590 // err(arg0, z054, __LINE__, 0, 0, Local1, c009)
591 // }
592 }
593
594 // Run-method
595 Method(MSC0)
596 {
597 Name(ts, "MSC0")
598
599 mZ00(ts)
600 mZ02(ts)
601 mZ05(ts)
602 mZ06(ts)
603 mZ07(ts)
604 mZ08(ts)
605 mZ0a(ts)
606 mZ0b(ts)
607 mZ0e(ts)
608 mZ0f(ts)
609 mZ10(ts)
610 mZ11(ts)
611 mZ12(ts)
612 mZ13(ts)
613 mZ14(ts)
614 mZ15(ts)
615 mZ16(ts)
616 }