1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45#include <acpi/acpi.h>
46#include "accommon.h"
47#include "acparser.h"
48#include "amlcode.h"
49#include "acdispat.h"
50#include "acinterp.h"
51#include "acnamesp.h"
52#include "acevents.h"
53#include "actables.h"
54
55#define _COMPONENT ACPI_DISPATCHER
56ACPI_MODULE_NAME("dsopcode")
57
58
59static acpi_status
60acpi_ds_execute_arguments(struct acpi_namespace_node *node,
61 struct acpi_namespace_node *scope_node,
62 u32 aml_length, u8 * aml_start);
63
64static acpi_status
65acpi_ds_init_buffer_field(u16 aml_opcode,
66 union acpi_operand_object *obj_desc,
67 union acpi_operand_object *buffer_desc,
68 union acpi_operand_object *offset_desc,
69 union acpi_operand_object *length_desc,
70 union acpi_operand_object *result_desc);
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87static acpi_status
88acpi_ds_execute_arguments(struct acpi_namespace_node *node,
89 struct acpi_namespace_node *scope_node,
90 u32 aml_length, u8 * aml_start)
91{
92 acpi_status status;
93 union acpi_parse_object *op;
94 struct acpi_walk_state *walk_state;
95
96 ACPI_FUNCTION_TRACE(ds_execute_arguments);
97
98
99
100
101 op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP);
102 if (!op) {
103 return_ACPI_STATUS(AE_NO_MEMORY);
104 }
105
106
107
108 op->common.node = scope_node;
109
110
111
112 walk_state = acpi_ds_create_walk_state(0, NULL, NULL, NULL);
113 if (!walk_state) {
114 status = AE_NO_MEMORY;
115 goto cleanup;
116 }
117
118 status = acpi_ds_init_aml_walk(walk_state, op, NULL, aml_start,
119 aml_length, NULL, ACPI_IMODE_LOAD_PASS1);
120 if (ACPI_FAILURE(status)) {
121 acpi_ds_delete_walk_state(walk_state);
122 goto cleanup;
123 }
124
125
126
127 walk_state->parse_flags = ACPI_PARSE_DEFERRED_OP;
128 walk_state->deferred_node = node;
129
130
131
132 status = acpi_ps_parse_aml(walk_state);
133 if (ACPI_FAILURE(status)) {
134 goto cleanup;
135 }
136
137
138
139 op->common.node = node;
140 acpi_ps_delete_parse_tree(op);
141
142
143
144 op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP);
145 if (!op) {
146 return_ACPI_STATUS(AE_NO_MEMORY);
147 }
148
149 op->common.node = scope_node;
150
151
152
153 walk_state = acpi_ds_create_walk_state(0, NULL, NULL, NULL);
154 if (!walk_state) {
155 status = AE_NO_MEMORY;
156 goto cleanup;
157 }
158
159
160
161 status = acpi_ds_init_aml_walk(walk_state, op, NULL, aml_start,
162 aml_length, NULL, ACPI_IMODE_EXECUTE);
163 if (ACPI_FAILURE(status)) {
164 acpi_ds_delete_walk_state(walk_state);
165 goto cleanup;
166 }
167
168
169
170 walk_state->deferred_node = node;
171 status = acpi_ps_parse_aml(walk_state);
172
173 cleanup:
174 acpi_ps_delete_parse_tree(op);
175 return_ACPI_STATUS(status);
176}
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191acpi_status
192acpi_ds_get_buffer_field_arguments(union acpi_operand_object *obj_desc)
193{
194 union acpi_operand_object *extra_desc;
195 struct acpi_namespace_node *node;
196 acpi_status status;
197
198 ACPI_FUNCTION_TRACE_PTR(ds_get_buffer_field_arguments, obj_desc);
199
200 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
201 return_ACPI_STATUS(AE_OK);
202 }
203
204
205
206 extra_desc = acpi_ns_get_secondary_object(obj_desc);
207 node = obj_desc->buffer_field.node;
208
209 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
210 (ACPI_TYPE_BUFFER_FIELD, node, NULL));
211 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] BufferField Arg Init\n",
212 acpi_ut_get_node_name(node)));
213
214
215
216 status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node),
217 extra_desc->extra.aml_length,
218 extra_desc->extra.aml_start);
219 return_ACPI_STATUS(status);
220}
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235acpi_status
236acpi_ds_get_bank_field_arguments(union acpi_operand_object *obj_desc)
237{
238 union acpi_operand_object *extra_desc;
239 struct acpi_namespace_node *node;
240 acpi_status status;
241
242 ACPI_FUNCTION_TRACE_PTR(ds_get_bank_field_arguments, obj_desc);
243
244 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
245 return_ACPI_STATUS(AE_OK);
246 }
247
248
249
250 extra_desc = acpi_ns_get_secondary_object(obj_desc);
251 node = obj_desc->bank_field.node;
252
253 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
254 (ACPI_TYPE_LOCAL_BANK_FIELD, node, NULL));
255 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] BankField Arg Init\n",
256 acpi_ut_get_node_name(node)));
257
258
259
260 status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node),
261 extra_desc->extra.aml_length,
262 extra_desc->extra.aml_start);
263 return_ACPI_STATUS(status);
264}
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279acpi_status acpi_ds_get_buffer_arguments(union acpi_operand_object *obj_desc)
280{
281 struct acpi_namespace_node *node;
282 acpi_status status;
283
284 ACPI_FUNCTION_TRACE_PTR(ds_get_buffer_arguments, obj_desc);
285
286 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
287 return_ACPI_STATUS(AE_OK);
288 }
289
290
291
292 node = obj_desc->buffer.node;
293 if (!node) {
294 ACPI_ERROR((AE_INFO,
295 "No pointer back to NS node in buffer obj %p",
296 obj_desc));
297 return_ACPI_STATUS(AE_AML_INTERNAL);
298 }
299
300 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Buffer Arg Init\n"));
301
302
303
304 status = acpi_ds_execute_arguments(node, node,
305 obj_desc->buffer.aml_length,
306 obj_desc->buffer.aml_start);
307 return_ACPI_STATUS(status);
308}
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323acpi_status acpi_ds_get_package_arguments(union acpi_operand_object *obj_desc)
324{
325 struct acpi_namespace_node *node;
326 acpi_status status;
327
328 ACPI_FUNCTION_TRACE_PTR(ds_get_package_arguments, obj_desc);
329
330 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
331 return_ACPI_STATUS(AE_OK);
332 }
333
334
335
336 node = obj_desc->package.node;
337 if (!node) {
338 ACPI_ERROR((AE_INFO,
339 "No pointer back to NS node in package %p",
340 obj_desc));
341 return_ACPI_STATUS(AE_AML_INTERNAL);
342 }
343
344 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Package Arg Init\n"));
345
346
347
348 status = acpi_ds_execute_arguments(node, node,
349 obj_desc->package.aml_length,
350 obj_desc->package.aml_start);
351 return_ACPI_STATUS(status);
352}
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367acpi_status acpi_ds_get_region_arguments(union acpi_operand_object *obj_desc)
368{
369 struct acpi_namespace_node *node;
370 acpi_status status;
371 union acpi_operand_object *extra_desc;
372
373 ACPI_FUNCTION_TRACE_PTR(ds_get_region_arguments, obj_desc);
374
375 if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
376 return_ACPI_STATUS(AE_OK);
377 }
378
379 extra_desc = acpi_ns_get_secondary_object(obj_desc);
380 if (!extra_desc) {
381 return_ACPI_STATUS(AE_NOT_EXIST);
382 }
383
384
385
386 node = obj_desc->region.node;
387
388 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
389 (ACPI_TYPE_REGION, node, NULL));
390
391 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] OpRegion Arg Init at AML %p\n",
392 acpi_ut_get_node_name(node),
393 extra_desc->extra.aml_start));
394
395
396
397 status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node),
398 extra_desc->extra.aml_length,
399 extra_desc->extra.aml_start);
400 if (ACPI_FAILURE(status)) {
401 return_ACPI_STATUS(status);
402 }
403
404
405
406 status = acpi_os_validate_address(obj_desc->region.space_id,
407 obj_desc->region.address,
408 (acpi_size) obj_desc->region.length,
409 acpi_ut_get_node_name(node));
410
411 if (ACPI_FAILURE(status)) {
412
413
414
415
416
417 ACPI_EXCEPTION((AE_INFO, status,
418 "During address validation of OpRegion [%4.4s]",
419 node->name.ascii));
420 obj_desc->common.flags |= AOPOBJ_INVALID;
421 status = AE_OK;
422 }
423
424 return_ACPI_STATUS(status);
425}
426
427
428
429
430
431
432
433
434
435
436
437
438
439acpi_status acpi_ds_initialize_region(acpi_handle obj_handle)
440{
441 union acpi_operand_object *obj_desc;
442 acpi_status status;
443
444 obj_desc = acpi_ns_get_attached_object(obj_handle);
445
446
447
448 status = acpi_ev_initialize_region(obj_desc, FALSE);
449 return (status);
450}
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469static acpi_status
470acpi_ds_init_buffer_field(u16 aml_opcode,
471 union acpi_operand_object *obj_desc,
472 union acpi_operand_object *buffer_desc,
473 union acpi_operand_object *offset_desc,
474 union acpi_operand_object *length_desc,
475 union acpi_operand_object *result_desc)
476{
477 u32 offset;
478 u32 bit_offset;
479 u32 bit_count;
480 u8 field_flags;
481 acpi_status status;
482
483 ACPI_FUNCTION_TRACE_PTR(ds_init_buffer_field, obj_desc);
484
485
486
487 if (buffer_desc->common.type != ACPI_TYPE_BUFFER) {
488 ACPI_ERROR((AE_INFO,
489 "Target of Create Field is not a Buffer object - %s",
490 acpi_ut_get_object_type_name(buffer_desc)));
491
492 status = AE_AML_OPERAND_TYPE;
493 goto cleanup;
494 }
495
496
497
498
499
500
501 if (ACPI_GET_DESCRIPTOR_TYPE(result_desc) != ACPI_DESC_TYPE_NAMED) {
502 ACPI_ERROR((AE_INFO,
503 "(%s) destination not a NS Node [%s]",
504 acpi_ps_get_opcode_name(aml_opcode),
505 acpi_ut_get_descriptor_name(result_desc)));
506
507 status = AE_AML_OPERAND_TYPE;
508 goto cleanup;
509 }
510
511 offset = (u32) offset_desc->integer.value;
512
513
514
515
516 switch (aml_opcode) {
517 case AML_CREATE_FIELD_OP:
518
519
520
521 field_flags = AML_FIELD_ACCESS_BYTE;
522 bit_offset = offset;
523 bit_count = (u32) length_desc->integer.value;
524
525
526
527 if (bit_count == 0) {
528 ACPI_ERROR((AE_INFO,
529 "Attempt to CreateField of length zero"));
530 status = AE_AML_OPERAND_VALUE;
531 goto cleanup;
532 }
533 break;
534
535 case AML_CREATE_BIT_FIELD_OP:
536
537
538
539 bit_offset = offset;
540 bit_count = 1;
541 field_flags = AML_FIELD_ACCESS_BYTE;
542 break;
543
544 case AML_CREATE_BYTE_FIELD_OP:
545
546
547
548 bit_offset = 8 * offset;
549 bit_count = 8;
550 field_flags = AML_FIELD_ACCESS_BYTE;
551 break;
552
553 case AML_CREATE_WORD_FIELD_OP:
554
555
556
557 bit_offset = 8 * offset;
558 bit_count = 16;
559 field_flags = AML_FIELD_ACCESS_WORD;
560 break;
561
562 case AML_CREATE_DWORD_FIELD_OP:
563
564
565
566 bit_offset = 8 * offset;
567 bit_count = 32;
568 field_flags = AML_FIELD_ACCESS_DWORD;
569 break;
570
571 case AML_CREATE_QWORD_FIELD_OP:
572
573
574
575 bit_offset = 8 * offset;
576 bit_count = 64;
577 field_flags = AML_FIELD_ACCESS_QWORD;
578 break;
579
580 default:
581
582 ACPI_ERROR((AE_INFO,
583 "Unknown field creation opcode %02x", aml_opcode));
584 status = AE_AML_BAD_OPCODE;
585 goto cleanup;
586 }
587
588
589
590 if ((bit_offset + bit_count) > (8 * (u32) buffer_desc->buffer.length)) {
591 ACPI_ERROR((AE_INFO,
592 "Field [%4.4s] at %d exceeds Buffer [%4.4s] size %d (bits)",
593 acpi_ut_get_node_name(result_desc),
594 bit_offset + bit_count,
595 acpi_ut_get_node_name(buffer_desc->buffer.node),
596 8 * (u32) buffer_desc->buffer.length));
597 status = AE_AML_BUFFER_LIMIT;
598 goto cleanup;
599 }
600
601
602
603
604
605
606 status = acpi_ex_prep_common_field_object(obj_desc, field_flags, 0,
607 bit_offset, bit_count);
608 if (ACPI_FAILURE(status)) {
609 goto cleanup;
610 }
611
612 obj_desc->buffer_field.buffer_obj = buffer_desc;
613
614
615
616 buffer_desc->common.reference_count = (u16)
617 (buffer_desc->common.reference_count +
618 obj_desc->common.reference_count);
619
620 cleanup:
621
622
623
624 acpi_ut_remove_reference(offset_desc);
625 acpi_ut_remove_reference(buffer_desc);
626
627 if (aml_opcode == AML_CREATE_FIELD_OP) {
628 acpi_ut_remove_reference(length_desc);
629 }
630
631
632
633 if (ACPI_FAILURE(status)) {
634 acpi_ut_remove_reference(result_desc);
635 } else {
636
637
638 obj_desc->buffer_field.flags |= AOPOBJ_DATA_VALID;
639 }
640
641 return_ACPI_STATUS(status);
642}
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658acpi_status
659acpi_ds_eval_buffer_field_operands(struct acpi_walk_state *walk_state,
660 union acpi_parse_object *op)
661{
662 acpi_status status;
663 union acpi_operand_object *obj_desc;
664 struct acpi_namespace_node *node;
665 union acpi_parse_object *next_op;
666
667 ACPI_FUNCTION_TRACE_PTR(ds_eval_buffer_field_operands, op);
668
669
670
671
672
673 node = op->common.node;
674
675
676
677 next_op = op->common.value.arg;
678
679
680
681 status = acpi_ds_create_operands(walk_state, next_op);
682 if (ACPI_FAILURE(status)) {
683 return_ACPI_STATUS(status);
684 }
685
686 obj_desc = acpi_ns_get_attached_object(node);
687 if (!obj_desc) {
688 return_ACPI_STATUS(AE_NOT_EXIST);
689 }
690
691
692
693 status = acpi_ex_resolve_operands(op->common.aml_opcode,
694 ACPI_WALK_OPERANDS, walk_state);
695 if (ACPI_FAILURE(status)) {
696 ACPI_ERROR((AE_INFO, "(%s) bad operand(s) (%X)",
697 acpi_ps_get_opcode_name(op->common.aml_opcode),
698 status));
699
700 return_ACPI_STATUS(status);
701 }
702
703
704
705 if (op->common.aml_opcode == AML_CREATE_FIELD_OP) {
706
707
708
709 status =
710 acpi_ds_init_buffer_field(op->common.aml_opcode, obj_desc,
711 walk_state->operands[0],
712 walk_state->operands[1],
713 walk_state->operands[2],
714 walk_state->operands[3]);
715 } else {
716
717
718 status =
719 acpi_ds_init_buffer_field(op->common.aml_opcode, obj_desc,
720 walk_state->operands[0],
721 walk_state->operands[1], NULL,
722 walk_state->operands[2]);
723 }
724
725 return_ACPI_STATUS(status);
726}
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742acpi_status
743acpi_ds_eval_region_operands(struct acpi_walk_state *walk_state,
744 union acpi_parse_object *op)
745{
746 acpi_status status;
747 union acpi_operand_object *obj_desc;
748 union acpi_operand_object *operand_desc;
749 struct acpi_namespace_node *node;
750 union acpi_parse_object *next_op;
751
752 ACPI_FUNCTION_TRACE_PTR(ds_eval_region_operands, op);
753
754
755
756
757
758 node = op->common.node;
759
760
761
762 next_op = op->common.value.arg;
763
764
765
766 next_op = next_op->common.next;
767
768
769
770 status = acpi_ds_create_operands(walk_state, next_op);
771 if (ACPI_FAILURE(status)) {
772 return_ACPI_STATUS(status);
773 }
774
775
776
777 status = acpi_ex_resolve_operands(op->common.aml_opcode,
778 ACPI_WALK_OPERANDS, walk_state);
779 if (ACPI_FAILURE(status)) {
780 return_ACPI_STATUS(status);
781 }
782
783 obj_desc = acpi_ns_get_attached_object(node);
784 if (!obj_desc) {
785 return_ACPI_STATUS(AE_NOT_EXIST);
786 }
787
788
789
790
791
792 operand_desc = walk_state->operands[walk_state->num_operands - 1];
793
794 obj_desc->region.length = (u32) operand_desc->integer.value;
795 acpi_ut_remove_reference(operand_desc);
796
797
798
799
800
801 operand_desc = walk_state->operands[walk_state->num_operands - 2];
802
803 obj_desc->region.address = (acpi_physical_address)
804 operand_desc->integer.value;
805 acpi_ut_remove_reference(operand_desc);
806
807 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n",
808 obj_desc,
809 ACPI_FORMAT_NATIVE_UINT(obj_desc->region.address),
810 obj_desc->region.length));
811
812
813
814 obj_desc->region.flags |= AOPOBJ_DATA_VALID;
815
816 return_ACPI_STATUS(status);
817}
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833acpi_status
834acpi_ds_eval_table_region_operands(struct acpi_walk_state *walk_state,
835 union acpi_parse_object *op)
836{
837 acpi_status status;
838 union acpi_operand_object *obj_desc;
839 union acpi_operand_object **operand;
840 struct acpi_namespace_node *node;
841 union acpi_parse_object *next_op;
842 u32 table_index;
843 struct acpi_table_header *table;
844
845 ACPI_FUNCTION_TRACE_PTR(ds_eval_table_region_operands, op);
846
847
848
849
850
851 node = op->common.node;
852
853
854
855 next_op = op->common.value.arg;
856
857
858
859
860
861 status = acpi_ds_create_operands(walk_state, next_op);
862 if (ACPI_FAILURE(status)) {
863 return_ACPI_STATUS(status);
864 }
865
866
867
868
869
870 status = acpi_ex_resolve_operands(op->common.aml_opcode,
871 ACPI_WALK_OPERANDS, walk_state);
872 if (ACPI_FAILURE(status)) {
873 return_ACPI_STATUS(status);
874 }
875
876 operand = &walk_state->operands[0];
877
878
879
880 status = acpi_tb_find_table(operand[0]->string.pointer,
881 operand[1]->string.pointer,
882 operand[2]->string.pointer, &table_index);
883 if (ACPI_FAILURE(status)) {
884 return_ACPI_STATUS(status);
885 }
886
887 acpi_ut_remove_reference(operand[0]);
888 acpi_ut_remove_reference(operand[1]);
889 acpi_ut_remove_reference(operand[2]);
890
891 status = acpi_get_table_by_index(table_index, &table);
892 if (ACPI_FAILURE(status)) {
893 return_ACPI_STATUS(status);
894 }
895
896 obj_desc = acpi_ns_get_attached_object(node);
897 if (!obj_desc) {
898 return_ACPI_STATUS(AE_NOT_EXIST);
899 }
900
901 obj_desc->region.address =
902 (acpi_physical_address) ACPI_TO_INTEGER(table);
903 obj_desc->region.length = table->length;
904
905 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n",
906 obj_desc,
907 ACPI_FORMAT_NATIVE_UINT(obj_desc->region.address),
908 obj_desc->region.length));
909
910
911
912 obj_desc->region.flags |= AOPOBJ_DATA_VALID;
913
914 return_ACPI_STATUS(status);
915}
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932acpi_status
933acpi_ds_eval_data_object_operands(struct acpi_walk_state *walk_state,
934 union acpi_parse_object *op,
935 union acpi_operand_object *obj_desc)
936{
937 acpi_status status;
938 union acpi_operand_object *arg_desc;
939 u32 length;
940
941 ACPI_FUNCTION_TRACE(ds_eval_data_object_operands);
942
943
944
945
946
947
948
949 walk_state->operand_index = walk_state->num_operands;
950
951 status = acpi_ds_create_operand(walk_state, op->common.value.arg, 1);
952 if (ACPI_FAILURE(status)) {
953 return_ACPI_STATUS(status);
954 }
955
956 status = acpi_ex_resolve_operands(walk_state->opcode,
957 &(walk_state->
958 operands[walk_state->num_operands -
959 1]), walk_state);
960 if (ACPI_FAILURE(status)) {
961 return_ACPI_STATUS(status);
962 }
963
964
965
966 arg_desc = walk_state->operands[walk_state->num_operands - 1];
967 length = (u32) arg_desc->integer.value;
968
969
970
971 status = acpi_ds_obj_stack_pop(1, walk_state);
972 if (ACPI_FAILURE(status)) {
973 return_ACPI_STATUS(status);
974 }
975
976 acpi_ut_remove_reference(arg_desc);
977
978
979
980
981 switch (op->common.aml_opcode) {
982 case AML_BUFFER_OP:
983
984 status =
985 acpi_ds_build_internal_buffer_obj(walk_state, op, length,
986 &obj_desc);
987 break;
988
989 case AML_PACKAGE_OP:
990 case AML_VAR_PACKAGE_OP:
991
992 status =
993 acpi_ds_build_internal_package_obj(walk_state, op, length,
994 &obj_desc);
995 break;
996
997 default:
998 return_ACPI_STATUS(AE_AML_BAD_OPCODE);
999 }
1000
1001 if (ACPI_SUCCESS(status)) {
1002
1003
1004
1005
1006
1007 if ((!op->common.parent) ||
1008 ((op->common.parent->common.aml_opcode != AML_PACKAGE_OP) &&
1009 (op->common.parent->common.aml_opcode !=
1010 AML_VAR_PACKAGE_OP)
1011 && (op->common.parent->common.aml_opcode != AML_NAME_OP))) {
1012 walk_state->result_obj = obj_desc;
1013 }
1014 }
1015
1016 return_ACPI_STATUS(status);
1017}
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033acpi_status
1034acpi_ds_eval_bank_field_operands(struct acpi_walk_state *walk_state,
1035 union acpi_parse_object *op)
1036{
1037 acpi_status status;
1038 union acpi_operand_object *obj_desc;
1039 union acpi_operand_object *operand_desc;
1040 struct acpi_namespace_node *node;
1041 union acpi_parse_object *next_op;
1042 union acpi_parse_object *arg;
1043
1044 ACPI_FUNCTION_TRACE_PTR(ds_eval_bank_field_operands, op);
1045
1046
1047
1048
1049
1050
1051
1052
1053 next_op = op->common.value.arg;
1054
1055
1056
1057 next_op = next_op->common.next;
1058
1059
1060
1061 next_op = next_op->common.next;
1062
1063
1064
1065
1066
1067
1068
1069 walk_state->operand_index = 0;
1070
1071 status = acpi_ds_create_operand(walk_state, next_op, 0);
1072 if (ACPI_FAILURE(status)) {
1073 return_ACPI_STATUS(status);
1074 }
1075
1076 status = acpi_ex_resolve_to_value(&walk_state->operands[0], walk_state);
1077 if (ACPI_FAILURE(status)) {
1078 return_ACPI_STATUS(status);
1079 }
1080
1081 ACPI_DUMP_OPERANDS(ACPI_WALK_OPERANDS,
1082 acpi_ps_get_opcode_name(op->common.aml_opcode), 1);
1083
1084
1085
1086
1087 operand_desc = walk_state->operands[0];
1088
1089
1090
1091 arg = acpi_ps_get_arg(op, 4);
1092 while (arg) {
1093
1094
1095
1096 if (arg->common.aml_opcode == AML_INT_NAMEDFIELD_OP) {
1097 node = arg->common.node;
1098
1099 obj_desc = acpi_ns_get_attached_object(node);
1100 if (!obj_desc) {
1101 return_ACPI_STATUS(AE_NOT_EXIST);
1102 }
1103
1104 obj_desc->bank_field.value =
1105 (u32) operand_desc->integer.value;
1106 }
1107
1108
1109
1110 arg = arg->common.next;
1111 }
1112
1113 acpi_ut_remove_reference(operand_desc);
1114 return_ACPI_STATUS(status);
1115}
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131acpi_status
1132acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state,
1133 union acpi_parse_object *op)
1134{
1135 acpi_status status = AE_OK;
1136 union acpi_generic_state *control_state;
1137
1138 ACPI_FUNCTION_NAME(ds_exec_begin_control_op);
1139
1140 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", op,
1141 op->common.aml_opcode, walk_state));
1142
1143 switch (op->common.aml_opcode) {
1144 case AML_WHILE_OP:
1145
1146
1147
1148
1149
1150 if (walk_state->control_state) {
1151 if (walk_state->control_state->control.aml_predicate_start
1152 == (walk_state->parser_state.aml - 1)) {
1153
1154
1155
1156 walk_state->control_state->common.state =
1157 ACPI_CONTROL_CONDITIONAL_EXECUTING;
1158 break;
1159 }
1160 }
1161
1162
1163
1164 case AML_IF_OP:
1165
1166
1167
1168
1169
1170
1171 control_state = acpi_ut_create_control_state();
1172 if (!control_state) {
1173 status = AE_NO_MEMORY;
1174 break;
1175 }
1176
1177
1178
1179
1180 control_state->control.aml_predicate_start =
1181 walk_state->parser_state.aml - 1;
1182 control_state->control.package_end =
1183 walk_state->parser_state.pkg_end;
1184 control_state->control.opcode = op->common.aml_opcode;
1185
1186
1187
1188 acpi_ut_push_generic_state(&walk_state->control_state,
1189 control_state);
1190 break;
1191
1192 case AML_ELSE_OP:
1193
1194
1195
1196
1197 if (walk_state->last_predicate) {
1198 status = AE_CTRL_TRUE;
1199 }
1200
1201 break;
1202
1203 case AML_RETURN_OP:
1204
1205 break;
1206
1207 default:
1208 break;
1209 }
1210
1211 return (status);
1212}
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228acpi_status
1229acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state,
1230 union acpi_parse_object * op)
1231{
1232 acpi_status status = AE_OK;
1233 union acpi_generic_state *control_state;
1234
1235 ACPI_FUNCTION_NAME(ds_exec_end_control_op);
1236
1237 switch (op->common.aml_opcode) {
1238 case AML_IF_OP:
1239
1240 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", op));
1241
1242
1243
1244
1245
1246 walk_state->last_predicate =
1247 (u8) walk_state->control_state->common.value;
1248
1249
1250
1251
1252
1253 control_state =
1254 acpi_ut_pop_generic_state(&walk_state->control_state);
1255 acpi_ut_delete_generic_state(control_state);
1256 break;
1257
1258 case AML_ELSE_OP:
1259
1260 break;
1261
1262 case AML_WHILE_OP:
1263
1264 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", op));
1265
1266 control_state = walk_state->control_state;
1267 if (control_state->common.value) {
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277 control_state->control.loop_count++;
1278 if (control_state->control.loop_count >
1279 ACPI_MAX_LOOP_ITERATIONS) {
1280 status = AE_AML_INFINITE_LOOP;
1281 break;
1282 }
1283
1284
1285
1286
1287
1288 status = AE_CTRL_PENDING;
1289 walk_state->aml_last_while =
1290 control_state->control.aml_predicate_start;
1291 break;
1292 }
1293
1294
1295
1296 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1297 "[WHILE_OP] termination! Op=%p\n", op));
1298
1299
1300
1301 control_state =
1302 acpi_ut_pop_generic_state(&walk_state->control_state);
1303 acpi_ut_delete_generic_state(control_state);
1304 break;
1305
1306 case AML_RETURN_OP:
1307
1308 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1309 "[RETURN_OP] Op=%p Arg=%p\n", op,
1310 op->common.value.arg));
1311
1312
1313
1314
1315
1316
1317 if (op->common.value.arg) {
1318
1319
1320
1321 acpi_ds_clear_implicit_return(walk_state);
1322
1323
1324
1325 status =
1326 acpi_ds_create_operands(walk_state,
1327 op->common.value.arg);
1328 if (ACPI_FAILURE(status)) {
1329 return (status);
1330 }
1331
1332
1333
1334
1335
1336
1337 status =
1338 acpi_ex_resolve_to_value(&walk_state->operands[0],
1339 walk_state);
1340 if (ACPI_FAILURE(status)) {
1341 return (status);
1342 }
1343
1344
1345
1346
1347
1348
1349 walk_state->return_desc = walk_state->operands[0];
1350 } else if (walk_state->result_count) {
1351
1352
1353
1354 acpi_ds_clear_implicit_return(walk_state);
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365 if ((ACPI_GET_DESCRIPTOR_TYPE
1366 (walk_state->results->results.obj_desc[0]) ==
1367 ACPI_DESC_TYPE_OPERAND)
1368 && ((walk_state->results->results.obj_desc[0])->
1369 common.type == ACPI_TYPE_LOCAL_REFERENCE)
1370 && ((walk_state->results->results.obj_desc[0])->
1371 reference.class != ACPI_REFCLASS_INDEX)) {
1372 status =
1373 acpi_ex_resolve_to_value(&walk_state->
1374 results->results.
1375 obj_desc[0],
1376 walk_state);
1377 if (ACPI_FAILURE(status)) {
1378 return (status);
1379 }
1380 }
1381
1382 walk_state->return_desc =
1383 walk_state->results->results.obj_desc[0];
1384 } else {
1385
1386
1387 if (walk_state->num_operands) {
1388 acpi_ut_remove_reference(walk_state->
1389 operands[0]);
1390 }
1391
1392 walk_state->operands[0] = NULL;
1393 walk_state->num_operands = 0;
1394 walk_state->return_desc = NULL;
1395 }
1396
1397 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1398 "Completed RETURN_OP State=%p, RetVal=%p\n",
1399 walk_state, walk_state->return_desc));
1400
1401
1402
1403 status = AE_CTRL_TERMINATE;
1404 break;
1405
1406 case AML_NOOP_OP:
1407
1408
1409 break;
1410
1411 case AML_BREAK_POINT_OP:
1412
1413
1414
1415
1416
1417
1418 ACPI_DEBUGGER_EXEC(acpi_gbl_cm_single_step = TRUE);
1419 ACPI_DEBUGGER_EXEC(acpi_os_printf
1420 ("**break** Executed AML BreakPoint opcode\n"));
1421
1422
1423
1424 status = acpi_os_signal(ACPI_SIGNAL_BREAKPOINT,
1425 "Executed AML Breakpoint opcode");
1426 break;
1427
1428 case AML_BREAK_OP:
1429 case AML_CONTINUE_OP:
1430
1431
1432
1433 while (walk_state->control_state &&
1434 (walk_state->control_state->control.opcode !=
1435 AML_WHILE_OP)) {
1436 control_state =
1437 acpi_ut_pop_generic_state(&walk_state->
1438 control_state);
1439 acpi_ut_delete_generic_state(control_state);
1440 }
1441
1442
1443
1444 if (!walk_state->control_state) {
1445 return (AE_AML_NO_WHILE);
1446 }
1447
1448
1449
1450 walk_state->aml_last_while =
1451 walk_state->control_state->control.package_end;
1452
1453
1454
1455 if (op->common.aml_opcode == AML_BREAK_OP) {
1456 status = AE_CTRL_BREAK;
1457 } else {
1458 status = AE_CTRL_CONTINUE;
1459 }
1460 break;
1461
1462 default:
1463
1464 ACPI_ERROR((AE_INFO, "Unknown control opcode=%X Op=%p",
1465 op->common.aml_opcode, op));
1466
1467 status = AE_AML_BAD_OPCODE;
1468 break;
1469 }
1470
1471 return (status);
1472}
1473