Loading...
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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 | /****************************************************************************** * * Module Name: dswstate - Dispatcher parse tree walk management routines * $Revision: 54 $ * *****************************************************************************/ /* * Copyright (C) 2000, 2001 R. Byron Moore * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "acpi.h" #include "amlcode.h" #include "acparser.h" #include "acdispat.h" #include "acnamesp.h" #include "acinterp.h" #define _COMPONENT ACPI_DISPATCHER MODULE_NAME ("dswstate") /******************************************************************************* * * FUNCTION: Acpi_ds_result_insert * * PARAMETERS: Object - Object to push * Walk_state - Current Walk state * * RETURN: Status * * DESCRIPTION: Push an object onto this walk's result stack * ******************************************************************************/ acpi_status acpi_ds_result_insert ( void *object, u32 index, acpi_walk_state *walk_state) { acpi_generic_state *state; PROC_NAME ("Ds_result_insert"); state = walk_state->results; if (!state) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result object pushed! State=%p\n", walk_state)); return (AE_NOT_EXIST); } if (index >= OBJ_NUM_OPERANDS) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Index out of range: %X Obj=%p State=%p Num=%X\n", index, object, walk_state, state->results.num_results)); return (AE_BAD_PARAMETER); } if (!object) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null Object! Index=%X Obj=%p State=%p Num=%X\n", index, object, walk_state, state->results.num_results)); return (AE_BAD_PARAMETER); } state->results.obj_desc [index] = object; state->results.num_results++; ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p Num=%X Cur=%X\n", object, object ? acpi_ut_get_type_name (((acpi_operand_object *) object)->common.type) : "NULL", walk_state, state->results.num_results, walk_state->current_result)); return (AE_OK); } /******************************************************************************* * * FUNCTION: Acpi_ds_result_remove * * PARAMETERS: Object - Where to return the popped object * Walk_state - Current Walk state * * RETURN: Status * * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In * other words, this is a FIFO. * ******************************************************************************/ acpi_status acpi_ds_result_remove ( acpi_operand_object **object, u32 index, acpi_walk_state *walk_state) { acpi_generic_state *state; PROC_NAME ("Ds_result_remove"); state = walk_state->results; if (!state) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result object pushed! State=%p\n", walk_state)); return (AE_NOT_EXIST); } if (index >= OBJ_NUM_OPERANDS) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Index out of range: %X State=%p Num=%X\n", index, walk_state, state->results.num_results)); } /* Check for a valid result object */ if (!state->results.obj_desc [index]) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null operand! State=%p #Ops=%X, Index=%X\n", walk_state, state->results.num_results, index)); return (AE_AML_NO_RETURN_VALUE); } /* Remove the object */ state->results.num_results--; *object = state->results.obj_desc [index]; state->results.obj_desc [index] = NULL; ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] Index=%X State=%p Num=%X\n", *object, (*object) ? acpi_ut_get_type_name ((*object)->common.type) : "NULL", index, walk_state, state->results.num_results)); return (AE_OK); } /******************************************************************************* * * FUNCTION: Acpi_ds_result_pop * * PARAMETERS: Object - Where to return the popped object * Walk_state - Current Walk state * * RETURN: Status * * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In * other words, this is a FIFO. * ******************************************************************************/ acpi_status acpi_ds_result_pop ( acpi_operand_object **object, acpi_walk_state *walk_state) { u32 index; acpi_generic_state *state; PROC_NAME ("Ds_result_pop"); state = walk_state->results; if (!state) { return (AE_OK); } if (!state->results.num_results) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Result stack is empty! State=%p\n", walk_state)); return (AE_AML_NO_RETURN_VALUE); } /* Remove top element */ state->results.num_results--; for (index = OBJ_NUM_OPERANDS; index; index--) { /* Check for a valid result object */ if (state->results.obj_desc [index -1]) { *object = state->results.obj_desc [index -1]; state->results.obj_desc [index -1] = NULL; ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] Index=%X State=%p Num=%X\n", *object, (*object) ? acpi_ut_get_type_name ((*object)->common.type) : "NULL", index -1, walk_state, state->results.num_results)); return (AE_OK); } } ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n", walk_state)); return (AE_AML_NO_RETURN_VALUE); } /******************************************************************************* * * FUNCTION: Acpi_ds_result_pop_from_bottom * * PARAMETERS: Object - Where to return the popped object * Walk_state - Current Walk state * * RETURN: Status * * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In * other words, this is a FIFO. * ******************************************************************************/ acpi_status acpi_ds_result_pop_from_bottom ( acpi_operand_object **object, acpi_walk_state *walk_state) { u32 index; acpi_generic_state *state; PROC_NAME ("Ds_result_pop_from_bottom"); state = walk_state->results; if (!state) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Warning: No result object pushed! State=%p\n", walk_state)); return (AE_NOT_EXIST); } if (!state->results.num_results) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n", walk_state)); return (AE_AML_NO_RETURN_VALUE); } /* Remove Bottom element */ *object = state->results.obj_desc [0]; /* Push entire stack down one element */ for (index = 0; index < state->results.num_results; index++) { state->results.obj_desc [index] = state->results.obj_desc [index + 1]; } state->results.num_results--; /* Check for a valid result object */ if (!*object) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null operand! State=%p #Ops=%X, Index=%X\n", walk_state, state->results.num_results, index)); return (AE_AML_NO_RETURN_VALUE); } ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s], Results=%p State=%p\n", *object, (*object) ? acpi_ut_get_type_name ((*object)->common.type) : "NULL", state, walk_state)); return (AE_OK); } /******************************************************************************* * * FUNCTION: Acpi_ds_result_push * * PARAMETERS: Object - Where to return the popped object * Walk_state - Current Walk state * * RETURN: Status * * DESCRIPTION: Push an object onto the current result stack * ******************************************************************************/ acpi_status acpi_ds_result_push ( acpi_operand_object *object, acpi_walk_state *walk_state) { acpi_generic_state *state; PROC_NAME ("Ds_result_push"); state = walk_state->results; if (!state) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result stack frame\n")); return (AE_AML_INTERNAL); } if (state->results.num_results == OBJ_NUM_OPERANDS) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Result stack overflow: Obj=%p State=%p Num=%X\n", object, walk_state, state->results.num_results)); return (AE_STACK_OVERFLOW); } if (!object) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null Object! Obj=%p State=%p Num=%X\n", object, walk_state, state->results.num_results)); return (AE_BAD_PARAMETER); } state->results.obj_desc [state->results.num_results] = object; state->results.num_results++; ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p Num=%X Cur=%X\n", object, object ? acpi_ut_get_type_name (((acpi_operand_object *) object)->common.type) : "NULL", walk_state, state->results.num_results, walk_state->current_result)); return (AE_OK); } /******************************************************************************* * * FUNCTION: Acpi_ds_result_stack_push * * PARAMETERS: Object - Object to push * Walk_state - Current Walk state * * RETURN: Status * * DESCRIPTION: * ******************************************************************************/ acpi_status acpi_ds_result_stack_push ( acpi_walk_state *walk_state) { acpi_generic_state *state; PROC_NAME ("Ds_result_stack_push"); state = acpi_ut_create_generic_state (); if (!state) { return (AE_NO_MEMORY); } state->common.data_type = ACPI_DESC_TYPE_STATE_RESULT; acpi_ut_push_generic_state (&walk_state->results, state); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Results=%p State=%p\n", state, walk_state)); return (AE_OK); } /******************************************************************************* * * FUNCTION: Acpi_ds_result_stack_pop * * PARAMETERS: Walk_state - Current Walk state * * RETURN: Status * * DESCRIPTION: * ******************************************************************************/ acpi_status acpi_ds_result_stack_pop ( acpi_walk_state *walk_state) { acpi_generic_state *state; PROC_NAME ("Ds_result_stack_pop"); /* Check for stack underflow */ if (walk_state->results == NULL) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Underflow - State=%p\n", walk_state)); return (AE_AML_NO_OPERAND); } state = acpi_ut_pop_generic_state (&walk_state->results); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Result=%p Remaining_results=%X State=%p\n", state, state->results.num_results, walk_state)); acpi_ut_delete_generic_state (state); return (AE_OK); } /******************************************************************************* * * FUNCTION: Acpi_ds_obj_stack_delete_all * * PARAMETERS: Walk_state - Current Walk state * * RETURN: Status * * DESCRIPTION: Clear the object stack by deleting all objects that are on it. * Should be used with great care, if at all! * ******************************************************************************/ acpi_status acpi_ds_obj_stack_delete_all ( acpi_walk_state *walk_state) { u32 i; FUNCTION_TRACE_PTR ("Ds_obj_stack_delete_all", walk_state); /* The stack size is configurable, but fixed */ for (i = 0; i < OBJ_NUM_OPERANDS; i++) { if (walk_state->operands[i]) { acpi_ut_remove_reference (walk_state->operands[i]); walk_state->operands[i] = NULL; } } return_ACPI_STATUS (AE_OK); } /******************************************************************************* * * FUNCTION: Acpi_ds_obj_stack_push * * PARAMETERS: Object - Object to push * Walk_state - Current Walk state * * RETURN: Status * * DESCRIPTION: Push an object onto this walk's object/operand stack * ******************************************************************************/ acpi_status acpi_ds_obj_stack_push ( void *object, acpi_walk_state *walk_state) { PROC_NAME ("Ds_obj_stack_push"); /* Check for stack overflow */ if (walk_state->num_operands >= OBJ_NUM_OPERANDS) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "overflow! Obj=%p State=%p #Ops=%X\n", object, walk_state, walk_state->num_operands)); return (AE_STACK_OVERFLOW); } /* Put the object onto the stack */ walk_state->operands [walk_state->num_operands] = object; walk_state->num_operands++; ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n", object, acpi_ut_get_type_name (((acpi_operand_object *) object)->common.type), walk_state, walk_state->num_operands)); return (AE_OK); } #if 0 /******************************************************************************* * * FUNCTION: Acpi_ds_obj_stack_pop_object * * PARAMETERS: Pop_count - Number of objects/entries to pop * Walk_state - Current Walk state * * RETURN: Status * * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT * deleted by this routine. * ******************************************************************************/ acpi_status acpi_ds_obj_stack_pop_object ( acpi_operand_object **object, acpi_walk_state *walk_state) { PROC_NAME ("Ds_obj_stack_pop_object"); /* Check for stack underflow */ if (walk_state->num_operands == 0) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Missing operand/stack empty! State=%p #Ops=%X\n", walk_state, walk_state->num_operands)); *object = NULL; return (AE_AML_NO_OPERAND); } /* Pop the stack */ walk_state->num_operands--; /* Check for a valid operand */ if (!walk_state->operands [walk_state->num_operands]) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null operand! State=%p #Ops=%X\n", walk_state, walk_state->num_operands)); *object = NULL; return (AE_AML_NO_OPERAND); } /* Get operand and set stack entry to null */ *object = walk_state->operands [walk_state->num_operands]; walk_state->operands [walk_state->num_operands] = NULL; ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n", *object, acpi_ut_get_type_name ((*object)->common.type), walk_state, walk_state->num_operands)); return (AE_OK); } #endif /******************************************************************************* * * FUNCTION: Acpi_ds_obj_stack_pop * * PARAMETERS: Pop_count - Number of objects/entries to pop * Walk_state - Current Walk state * * RETURN: Status * * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT * deleted by this routine. * ******************************************************************************/ acpi_status acpi_ds_obj_stack_pop ( u32 pop_count, acpi_walk_state *walk_state) { u32 i; PROC_NAME ("Ds_obj_stack_pop"); for (i = 0; i < pop_count; i++) { /* Check for stack underflow */ if (walk_state->num_operands == 0) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Underflow! Count=%X State=%p #Ops=%X\n", pop_count, walk_state, walk_state->num_operands)); return (AE_STACK_UNDERFLOW); } /* Just set the stack entry to null */ walk_state->num_operands--; walk_state->operands [walk_state->num_operands] = NULL; } ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n", pop_count, walk_state, walk_state->num_operands)); return (AE_OK); } /******************************************************************************* * * FUNCTION: Acpi_ds_obj_stack_pop_and_delete * * PARAMETERS: Pop_count - Number of objects/entries to pop * Walk_state - Current Walk state * * RETURN: Status * * DESCRIPTION: Pop this walk's object stack and delete each object that is * popped off. * ******************************************************************************/ acpi_status acpi_ds_obj_stack_pop_and_delete ( u32 pop_count, acpi_walk_state *walk_state) { u32 i; acpi_operand_object *obj_desc; PROC_NAME ("Ds_obj_stack_pop_and_delete"); for (i = 0; i < pop_count; i++) { /* Check for stack underflow */ if (walk_state->num_operands == 0) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Underflow! Count=%X State=%p #Ops=%X\n", pop_count, walk_state, walk_state->num_operands)); return (AE_STACK_UNDERFLOW); } /* Pop the stack and delete an object if present in this stack entry */ walk_state->num_operands--; obj_desc = walk_state->operands [walk_state->num_operands]; if (obj_desc) { acpi_ut_remove_reference (walk_state->operands [walk_state->num_operands]); walk_state->operands [walk_state->num_operands] = NULL; } } ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n", pop_count, walk_state, walk_state->num_operands)); return (AE_OK); } /******************************************************************************* * * FUNCTION: Acpi_ds_obj_stack_get_value * * PARAMETERS: Index - Stack index whose value is desired. Based * on the top of the stack (index=0 == top) * Walk_state - Current Walk state * * RETURN: Status * * DESCRIPTION: Retrieve an object from this walk's object stack. Index must * be within the range of the current stack pointer. * ******************************************************************************/ void * acpi_ds_obj_stack_get_value ( u32 index, acpi_walk_state *walk_state) { FUNCTION_TRACE_PTR ("Ds_obj_stack_get_value", walk_state); /* Can't do it if the stack is empty */ if (walk_state->num_operands == 0) { return_PTR (NULL); } /* or if the index is past the top of the stack */ if (index > (walk_state->num_operands - (u32) 1)) { return_PTR (NULL); } return_PTR (walk_state->operands[(NATIVE_UINT)(walk_state->num_operands - 1) - index]); } /******************************************************************************* * * FUNCTION: Acpi_ds_get_current_walk_state * * PARAMETERS: Walk_list - Get current active state for this walk list * * RETURN: Pointer to the current walk state * * DESCRIPTION: Get the walk state that is at the head of the list (the "current" * walk state. * ******************************************************************************/ acpi_walk_state * acpi_ds_get_current_walk_state ( acpi_walk_list *walk_list) { PROC_NAME ("Ds_get_current_walk_state"); ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Ds_get_current_walk_state, =%p\n", walk_list->walk_state)); if (!walk_list) { return (NULL); } return (walk_list->walk_state); } /******************************************************************************* * * FUNCTION: Acpi_ds_push_walk_state * * PARAMETERS: Walk_state - State to push * Walk_list - The list that owns the walk stack * * RETURN: None * * DESCRIPTION: Place the Walk_state at the head of the state list. * ******************************************************************************/ void acpi_ds_push_walk_state ( acpi_walk_state *walk_state, acpi_walk_list *walk_list) { FUNCTION_TRACE ("Ds_push_walk_state"); walk_state->next = walk_list->walk_state; walk_list->walk_state = walk_state; return_VOID; } /******************************************************************************* * * FUNCTION: Acpi_ds_pop_walk_state * * PARAMETERS: Walk_list - The list that owns the walk stack * * RETURN: A Walk_state object popped from the stack * * DESCRIPTION: Remove and return the walkstate object that is at the head of * the walk stack for the given walk list. NULL indicates that * the list is empty. * ******************************************************************************/ acpi_walk_state * acpi_ds_pop_walk_state ( acpi_walk_list *walk_list) { acpi_walk_state *walk_state; FUNCTION_TRACE ("Ds_pop_walk_state"); walk_state = walk_list->walk_state; if (walk_state) { /* Next walk state becomes the current walk state */ walk_list->walk_state = walk_state->next; /* * Don't clear the NEXT field, this serves as an indicator * that there is a parent WALK STATE * Walk_state->Next = NULL; */ } return_PTR (walk_state); } /******************************************************************************* * * FUNCTION: Acpi_ds_create_walk_state * * PARAMETERS: Origin - Starting point for this walk * Walk_list - Owning walk list * * RETURN: Pointer to the new walk state. * * DESCRIPTION: Allocate and initialize a new walk state. The current walk state * is set to this new state. * ******************************************************************************/ acpi_walk_state * acpi_ds_create_walk_state ( acpi_owner_id owner_id, acpi_parse_object *origin, acpi_operand_object *mth_desc, acpi_walk_list *walk_list) { acpi_walk_state *walk_state; acpi_status status; FUNCTION_TRACE ("Ds_create_walk_state"); walk_state = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_WALK); if (!walk_state) { return_PTR (NULL); } walk_state->data_type = ACPI_DESC_TYPE_WALK; walk_state->owner_id = owner_id; walk_state->origin = origin; walk_state->method_desc = mth_desc; walk_state->walk_list = walk_list; /* Init the method args/local */ #ifndef _ACPI_ASL_COMPILER acpi_ds_method_data_init (walk_state); #endif /* Create an initial result stack entry */ status = acpi_ds_result_stack_push (walk_state); if (ACPI_FAILURE (status)) { return_PTR (NULL); } /* Put the new state at the head of the walk list */ if (walk_list) { acpi_ds_push_walk_state (walk_state, walk_list); } return_PTR (walk_state); } #ifndef _ACPI_ASL_COMPILER /******************************************************************************* * * FUNCTION: Acpi_ds_init_aml_walk * * PARAMETERS: Walk_state - New state to be initialized * * RETURN: None * * DESCRIPTION: Initialize a walk state for a pass 1 or 2 parse tree walk * ******************************************************************************/ acpi_status acpi_ds_init_aml_walk ( acpi_walk_state *walk_state, acpi_parse_object *op, acpi_namespace_node *method_node, u8 *aml_start, u32 aml_length, acpi_operand_object **params, acpi_operand_object **return_obj_desc, u32 pass_number) { acpi_status status; acpi_parse_state *parser_state = &walk_state->parser_state; FUNCTION_TRACE ("Ds_init_aml_walk"); walk_state->parser_state.aml = walk_state->parser_state.aml_start = aml_start; walk_state->parser_state.aml_end = walk_state->parser_state.pkg_end = aml_start + aml_length; /* The Next_op of the Next_walk will be the beginning of the method */ /* TBD: [Restructure] -- obsolete? */ walk_state->next_op = NULL; walk_state->params = params; walk_state->caller_return_desc = return_obj_desc; status = acpi_ps_init_scope (&walk_state->parser_state, op); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } if (method_node) { walk_state->parser_state.start_node = method_node; walk_state->walk_type = WALK_METHOD; walk_state->method_node = method_node; walk_state->method_desc = acpi_ns_get_attached_object (method_node); /* Push start scope on scope stack and make it current */ status = acpi_ds_scope_stack_push (method_node, ACPI_TYPE_METHOD, walk_state); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } /* Init the method arguments */ acpi_ds_method_data_init_args (params, MTH_NUM_ARGS, walk_state); } else { /* Setup the current scope */ parser_state->start_node = parser_state->start_op->node; if (parser_state->start_node) { /* Push start scope on scope stack and make it current */ status = acpi_ds_scope_stack_push (parser_state->start_node, parser_state->start_node->type, walk_state); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } } } acpi_ds_init_callbacks (walk_state, pass_number); return_ACPI_STATUS (AE_OK); } #endif /******************************************************************************* * * FUNCTION: Acpi_ds_delete_walk_state * * PARAMETERS: Walk_state - State to delete * * RETURN: Status * * DESCRIPTION: Delete a walk state including all internal data structures * ******************************************************************************/ void acpi_ds_delete_walk_state ( acpi_walk_state *walk_state) { acpi_generic_state *state; FUNCTION_TRACE_PTR ("Ds_delete_walk_state", walk_state); if (!walk_state) { return; } if (walk_state->data_type != ACPI_DESC_TYPE_WALK) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p is not a valid walk state\n", walk_state)); return; } if (walk_state->parser_state.scope) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p walk still has a scope list\n", walk_state)); } /* Always must free any linked control states */ while (walk_state->control_state) { state = walk_state->control_state; walk_state->control_state = state->common.next; acpi_ut_delete_generic_state (state); } /* Always must free any linked parse states */ while (walk_state->scope_info) { state = walk_state->scope_info; walk_state->scope_info = state->common.next; acpi_ut_delete_generic_state (state); } /* Always must free any stacked result states */ while (walk_state->results) { state = walk_state->results; walk_state->results = state->common.next; acpi_ut_delete_generic_state (state); } acpi_ut_release_to_cache (ACPI_MEM_LIST_WALK, walk_state); return_VOID; } /****************************************************************************** * * FUNCTION: Acpi_ds_delete_walk_state_cache * * PARAMETERS: None * * RETURN: Status * * DESCRIPTION: Purge the global state object cache. Used during subsystem * termination. * ******************************************************************************/ void acpi_ds_delete_walk_state_cache ( void) { FUNCTION_TRACE ("Ds_delete_walk_state_cache"); acpi_ut_delete_generic_cache (ACPI_MEM_LIST_WALK); return_VOID; } |