1 /******************************************************************************* 2 * 3 * Module Name: rsutils - Utilities for the resource manager 4 * 5 ******************************************************************************/ 6 7 /****************************************************************************** 8 * 9 * 1. Copyright Notice 10 * 11 * Some or all of this work - Copyright (c) 1999 - 2016, Intel Corp. 12 * All rights reserved. 13 * 14 * 2. License 15 * 16 * 2.1. This is your license from Intel Corp. under its intellectual property 17 * rights. You may have additional license terms from the party that provided 18 * you this software, covering your right to use that party's intellectual 19 * property rights. 20 * 21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22 * copy of the source code appearing in this file ("Covered Code") an 23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24 * base code distributed originally by Intel ("Original Intel Code") to copy, 25 * make derivatives, distribute, use and display any portion of the Covered 26 * Code in any form, with the right to sublicense such rights; and 27 * 28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29 * license (with the right to sublicense), under only those claims of Intel 30 * patents that are infringed by the Original Intel Code, to make, use, sell, 31 * offer to sell, and import the Covered Code and derivative works thereof 32 * solely to the minimum extent necessary to exercise the above copyright 33 * license, and in no event shall the patent license extend to any additions 34 * to or modifications of the Original Intel Code. No other license or right 35 * is granted directly or by implication, estoppel or otherwise; 36 * 37 * The above copyright and patent license is granted only if the following 38 * conditions are met: 39 * 40 * 3. Conditions 41 * 42 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43 * Redistribution of source code of any substantial portion of the Covered 44 * Code or modification with rights to further distribute source must include 45 * the above Copyright Notice, the above License, this list of Conditions, 46 * and the following Disclaimer and Export Compliance provision. In addition, 47 * Licensee must cause all Covered Code to which Licensee contributes to 48 * contain a file documenting the changes Licensee made to create that Covered 49 * Code and the date of any change. Licensee must include in that file the 50 * documentation of any changes made by any predecessor Licensee. Licensee 51 * must include a prominent statement that the modification is derived, 52 * directly or indirectly, from Original Intel Code. 53 * 54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55 * Redistribution of source code of any substantial portion of the Covered 56 * Code or modification without rights to further distribute source must 57 * include the following Disclaimer and Export Compliance provision in the 58 * documentation and/or other materials provided with distribution. In 59 * addition, Licensee may not authorize further sublicense of source of any 60 * portion of the Covered Code, and must include terms to the effect that the 61 * license from Licensee to its licensee is limited to the intellectual 62 * property embodied in the software Licensee provides to its licensee, and 63 * not to intellectual property embodied in modifications its licensee may 64 * make. 65 * 66 * 3.3. Redistribution of Executable. Redistribution in executable form of any 67 * substantial portion of the Covered Code or modification must reproduce the 68 * above Copyright Notice, and the following Disclaimer and Export Compliance 69 * provision in the documentation and/or other materials provided with the 70 * distribution. 71 * 72 * 3.4. Intel retains all right, title, and interest in and to the Original 73 * Intel Code. 74 * 75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76 * Intel shall be used in advertising or otherwise to promote the sale, use or 77 * other dealings in products derived from or relating to the Covered Code 78 * without prior written authorization from Intel. 79 * 80 * 4. Disclaimer and Export Compliance 81 * 82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88 * PARTICULAR PURPOSE. 89 * 90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97 * LIMITED REMEDY. 98 * 99 * 4.3. Licensee shall not export, either directly or indirectly, any of this 100 * software or system incorporating such software without first obtaining any 101 * required license or other approval from the U. S. Department of Commerce or 102 * any other agency or department of the United States Government. In the 103 * event Licensee exports any such software from the United States or 104 * re-exports any such software from a foreign destination, Licensee shall 105 * ensure that the distribution and export/re-export of the software is in 106 * compliance with all laws, regulations, orders, or other restrictions of the 107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108 * any of its subsidiaries will export/re-export any technical data, process, 109 * software, or service, directly or indirectly, to any country for which the 110 * United States government or any agency thereof requires an export license, 111 * other governmental approval, or letter of assurance, without first obtaining 112 * such license, approval or letter. 113 * 114 *****************************************************************************/ 115 116 #include "acpi.h" 117 #include "accommon.h" 118 #include "acnamesp.h" 119 #include "acresrc.h" 120 121 122 #define _COMPONENT ACPI_RESOURCES 123 ACPI_MODULE_NAME ("rsutils") 124 125 126 /******************************************************************************* 127 * 128 * FUNCTION: AcpiRsDecodeBitmask 129 * 130 * PARAMETERS: Mask - Bitmask to decode 131 * List - Where the converted list is returned 132 * 133 * RETURN: Count of bits set (length of list) 134 * 135 * DESCRIPTION: Convert a bit mask into a list of values 136 * 137 ******************************************************************************/ 138 139 UINT8 140 AcpiRsDecodeBitmask ( 141 UINT16 Mask, 142 UINT8 *List) 143 { 144 UINT8 i; 145 UINT8 BitCount; 146 147 148 ACPI_FUNCTION_ENTRY (); 149 150 151 /* Decode the mask bits */ 152 153 for (i = 0, BitCount = 0; Mask; i++) 154 { 155 if (Mask & 0x0001) 156 { 157 List[BitCount] = i; 158 BitCount++; 159 } 160 161 Mask >>= 1; 162 } 163 164 return (BitCount); 165 } 166 167 168 /******************************************************************************* 169 * 170 * FUNCTION: AcpiRsEncodeBitmask 171 * 172 * PARAMETERS: List - List of values to encode 173 * Count - Length of list 174 * 175 * RETURN: Encoded bitmask 176 * 177 * DESCRIPTION: Convert a list of values to an encoded bitmask 178 * 179 ******************************************************************************/ 180 181 UINT16 182 AcpiRsEncodeBitmask ( 183 UINT8 *List, 184 UINT8 Count) 185 { 186 UINT32 i; 187 UINT16 Mask; 188 189 190 ACPI_FUNCTION_ENTRY (); 191 192 193 /* Encode the list into a single bitmask */ 194 195 for (i = 0, Mask = 0; i < Count; i++) 196 { 197 Mask |= (0x1 << List[i]); 198 } 199 200 return (Mask); 201 } 202 203 204 /******************************************************************************* 205 * 206 * FUNCTION: AcpiRsMoveData 207 * 208 * PARAMETERS: Destination - Pointer to the destination descriptor 209 * Source - Pointer to the source descriptor 210 * ItemCount - How many items to move 211 * MoveType - Byte width 212 * 213 * RETURN: None 214 * 215 * DESCRIPTION: Move multiple data items from one descriptor to another. Handles 216 * alignment issues and endian issues if necessary, as configured 217 * via the ACPI_MOVE_* macros. (This is why a memcpy is not used) 218 * 219 ******************************************************************************/ 220 221 void 222 AcpiRsMoveData ( 223 void *Destination, 224 void *Source, 225 UINT16 ItemCount, 226 UINT8 MoveType) 227 { 228 UINT32 i; 229 230 231 ACPI_FUNCTION_ENTRY (); 232 233 234 /* One move per item */ 235 236 for (i = 0; i < ItemCount; i++) 237 { 238 switch (MoveType) 239 { 240 /* 241 * For the 8-bit case, we can perform the move all at once 242 * since there are no alignment or endian issues 243 */ 244 case ACPI_RSC_MOVE8: 245 case ACPI_RSC_MOVE_GPIO_RES: 246 case ACPI_RSC_MOVE_SERIAL_VEN: 247 case ACPI_RSC_MOVE_SERIAL_RES: 248 249 memcpy (Destination, Source, ItemCount); 250 return; 251 252 /* 253 * 16-, 32-, and 64-bit cases must use the move macros that perform 254 * endian conversion and/or accommodate hardware that cannot perform 255 * misaligned memory transfers 256 */ 257 case ACPI_RSC_MOVE16: 258 case ACPI_RSC_MOVE_GPIO_PIN: 259 260 ACPI_MOVE_16_TO_16 ( 261 &ACPI_CAST_PTR (UINT16, Destination)[i], 262 &ACPI_CAST_PTR (UINT16, Source)[i]); 263 break; 264 265 case ACPI_RSC_MOVE32: 266 267 ACPI_MOVE_32_TO_32 ( 268 &ACPI_CAST_PTR (UINT32, Destination)[i], 269 &ACPI_CAST_PTR (UINT32, Source)[i]); 270 break; 271 272 case ACPI_RSC_MOVE64: 273 274 ACPI_MOVE_64_TO_64 ( 275 &ACPI_CAST_PTR (UINT64, Destination)[i], 276 &ACPI_CAST_PTR (UINT64, Source)[i]); 277 break; 278 279 default: 280 281 return; 282 } 283 } 284 } 285 286 287 /******************************************************************************* 288 * 289 * FUNCTION: AcpiRsSetResourceLength 290 * 291 * PARAMETERS: TotalLength - Length of the AML descriptor, including 292 * the header and length fields. 293 * Aml - Pointer to the raw AML descriptor 294 * 295 * RETURN: None 296 * 297 * DESCRIPTION: Set the ResourceLength field of an AML 298 * resource descriptor, both Large and Small descriptors are 299 * supported automatically. Note: Descriptor Type field must 300 * be valid. 301 * 302 ******************************************************************************/ 303 304 void 305 AcpiRsSetResourceLength ( 306 ACPI_RSDESC_SIZE TotalLength, 307 AML_RESOURCE *Aml) 308 { 309 ACPI_RS_LENGTH ResourceLength; 310 311 312 ACPI_FUNCTION_ENTRY (); 313 314 315 /* Length is the total descriptor length minus the header length */ 316 317 ResourceLength = (ACPI_RS_LENGTH) 318 (TotalLength - AcpiUtGetResourceHeaderLength (Aml)); 319 320 /* Length is stored differently for large and small descriptors */ 321 322 if (Aml->SmallHeader.DescriptorType & ACPI_RESOURCE_NAME_LARGE) 323 { 324 /* Large descriptor -- bytes 1-2 contain the 16-bit length */ 325 326 ACPI_MOVE_16_TO_16 ( 327 &Aml->LargeHeader.ResourceLength, &ResourceLength); 328 } 329 else 330 { 331 /* 332 * Small descriptor -- bits 2:0 of byte 0 contain the length 333 * Clear any existing length, preserving descriptor type bits 334 */ 335 Aml->SmallHeader.DescriptorType = (UINT8) 336 ((Aml->SmallHeader.DescriptorType & 337 ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK) 338 | ResourceLength); 339 } 340 } 341 342 343 /******************************************************************************* 344 * 345 * FUNCTION: AcpiRsSetResourceHeader 346 * 347 * PARAMETERS: DescriptorType - Byte to be inserted as the type 348 * TotalLength - Length of the AML descriptor, including 349 * the header and length fields. 350 * Aml - Pointer to the raw AML descriptor 351 * 352 * RETURN: None 353 * 354 * DESCRIPTION: Set the DescriptorType and ResourceLength fields of an AML 355 * resource descriptor, both Large and Small descriptors are 356 * supported automatically 357 * 358 ******************************************************************************/ 359 360 void 361 AcpiRsSetResourceHeader ( 362 UINT8 DescriptorType, 363 ACPI_RSDESC_SIZE TotalLength, 364 AML_RESOURCE *Aml) 365 { 366 ACPI_FUNCTION_ENTRY (); 367 368 369 /* Set the Resource Type */ 370 371 Aml->SmallHeader.DescriptorType = DescriptorType; 372 373 /* Set the Resource Length */ 374 375 AcpiRsSetResourceLength (TotalLength, Aml); 376 } 377 378 379 /******************************************************************************* 380 * 381 * FUNCTION: AcpiRsStrcpy 382 * 383 * PARAMETERS: Destination - Pointer to the destination string 384 * Source - Pointer to the source string 385 * 386 * RETURN: String length, including NULL terminator 387 * 388 * DESCRIPTION: Local string copy that returns the string length, saving a 389 * strcpy followed by a strlen. 390 * 391 ******************************************************************************/ 392 393 static UINT16 394 AcpiRsStrcpy ( 395 char *Destination, 396 char *Source) 397 { 398 UINT16 i; 399 400 401 ACPI_FUNCTION_ENTRY (); 402 403 404 for (i = 0; Source[i]; i++) 405 { 406 Destination[i] = Source[i]; 407 } 408 409 Destination[i] = 0; 410 411 /* Return string length including the NULL terminator */ 412 413 return ((UINT16) (i + 1)); 414 } 415 416 417 /******************************************************************************* 418 * 419 * FUNCTION: AcpiRsGetResourceSource 420 * 421 * PARAMETERS: ResourceLength - Length field of the descriptor 422 * MinimumLength - Minimum length of the descriptor (minus 423 * any optional fields) 424 * ResourceSource - Where the ResourceSource is returned 425 * Aml - Pointer to the raw AML descriptor 426 * StringPtr - (optional) where to store the actual 427 * ResourceSource string 428 * 429 * RETURN: Length of the string plus NULL terminator, rounded up to native 430 * word boundary 431 * 432 * DESCRIPTION: Copy the optional ResourceSource data from a raw AML descriptor 433 * to an internal resource descriptor 434 * 435 ******************************************************************************/ 436 437 ACPI_RS_LENGTH 438 AcpiRsGetResourceSource ( 439 ACPI_RS_LENGTH ResourceLength, 440 ACPI_RS_LENGTH MinimumLength, 441 ACPI_RESOURCE_SOURCE *ResourceSource, 442 AML_RESOURCE *Aml, 443 char *StringPtr) 444 { 445 ACPI_RSDESC_SIZE TotalLength; 446 UINT8 *AmlResourceSource; 447 448 449 ACPI_FUNCTION_ENTRY (); 450 451 452 TotalLength = ResourceLength + sizeof (AML_RESOURCE_LARGE_HEADER); 453 AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength); 454 455 /* 456 * ResourceSource is present if the length of the descriptor is longer 457 * than the minimum length. 458 * 459 * Note: Some resource descriptors will have an additional null, so 460 * we add 1 to the minimum length. 461 */ 462 if (TotalLength > (ACPI_RSDESC_SIZE) (MinimumLength + 1)) 463 { 464 /* Get the ResourceSourceIndex */ 465 466 ResourceSource->Index = AmlResourceSource[0]; 467 468 ResourceSource->StringPtr = StringPtr; 469 if (!StringPtr) 470 { 471 /* 472 * String destination pointer is not specified; Set the String 473 * pointer to the end of the current ResourceSource structure. 474 */ 475 ResourceSource->StringPtr = ACPI_ADD_PTR ( 476 char, ResourceSource, sizeof (ACPI_RESOURCE_SOURCE)); 477 } 478 479 /* 480 * In order for the Resource length to be a multiple of the native 481 * word, calculate the length of the string (+1 for NULL terminator) 482 * and expand to the next word multiple. 483 * 484 * Zero the entire area of the buffer. 485 */ 486 TotalLength = (UINT32) strlen ( 487 ACPI_CAST_PTR (char, &AmlResourceSource[1])) + 1; 488 489 TotalLength = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (TotalLength); 490 491 memset (ResourceSource->StringPtr, 0, TotalLength); 492 493 /* Copy the ResourceSource string to the destination */ 494 495 ResourceSource->StringLength = AcpiRsStrcpy ( 496 ResourceSource->StringPtr, 497 ACPI_CAST_PTR (char, &AmlResourceSource[1])); 498 499 return ((ACPI_RS_LENGTH) TotalLength); 500 } 501 502 /* ResourceSource is not present */ 503 504 ResourceSource->Index = 0; 505 ResourceSource->StringLength = 0; 506 ResourceSource->StringPtr = NULL; 507 return (0); 508 } 509 510 511 /******************************************************************************* 512 * 513 * FUNCTION: AcpiRsSetResourceSource 514 * 515 * PARAMETERS: Aml - Pointer to the raw AML descriptor 516 * MinimumLength - Minimum length of the descriptor (minus 517 * any optional fields) 518 * ResourceSource - Internal ResourceSource 519 520 * 521 * RETURN: Total length of the AML descriptor 522 * 523 * DESCRIPTION: Convert an optional ResourceSource from internal format to a 524 * raw AML resource descriptor 525 * 526 ******************************************************************************/ 527 528 ACPI_RSDESC_SIZE 529 AcpiRsSetResourceSource ( 530 AML_RESOURCE *Aml, 531 ACPI_RS_LENGTH MinimumLength, 532 ACPI_RESOURCE_SOURCE *ResourceSource) 533 { 534 UINT8 *AmlResourceSource; 535 ACPI_RSDESC_SIZE DescriptorLength; 536 537 538 ACPI_FUNCTION_ENTRY (); 539 540 541 DescriptorLength = MinimumLength; 542 543 /* Non-zero string length indicates presence of a ResourceSource */ 544 545 if (ResourceSource->StringLength) 546 { 547 /* Point to the end of the AML descriptor */ 548 549 AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength); 550 551 /* Copy the ResourceSourceIndex */ 552 553 AmlResourceSource[0] = (UINT8) ResourceSource->Index; 554 555 /* Copy the ResourceSource string */ 556 557 strcpy (ACPI_CAST_PTR (char, &AmlResourceSource[1]), 558 ResourceSource->StringPtr); 559 560 /* 561 * Add the length of the string (+ 1 for null terminator) to the 562 * final descriptor length 563 */ 564 DescriptorLength += ((ACPI_RSDESC_SIZE) 565 ResourceSource->StringLength + 1); 566 } 567 568 /* Return the new total length of the AML descriptor */ 569 570 return (DescriptorLength); 571 } 572 573 574 /******************************************************************************* 575 * 576 * FUNCTION: AcpiRsGetPrtMethodData 577 * 578 * PARAMETERS: Node - Device node 579 * RetBuffer - Pointer to a buffer structure for the 580 * results 581 * 582 * RETURN: Status 583 * 584 * DESCRIPTION: This function is called to get the _PRT value of an object 585 * contained in an object specified by the handle passed in 586 * 587 * If the function fails an appropriate status will be returned 588 * and the contents of the callers buffer is undefined. 589 * 590 ******************************************************************************/ 591 592 ACPI_STATUS 593 AcpiRsGetPrtMethodData ( 594 ACPI_NAMESPACE_NODE *Node, 595 ACPI_BUFFER *RetBuffer) 596 { 597 ACPI_OPERAND_OBJECT *ObjDesc; 598 ACPI_STATUS Status; 599 600 601 ACPI_FUNCTION_TRACE (RsGetPrtMethodData); 602 603 604 /* Parameters guaranteed valid by caller */ 605 606 /* Execute the method, no parameters */ 607 608 Status = AcpiUtEvaluateObject ( 609 Node, METHOD_NAME__PRT, ACPI_BTYPE_PACKAGE, &ObjDesc); 610 if (ACPI_FAILURE (Status)) 611 { 612 return_ACPI_STATUS (Status); 613 } 614 615 /* 616 * Create a resource linked list from the byte stream buffer that comes 617 * back from the _CRS method execution. 618 */ 619 Status = AcpiRsCreatePciRoutingTable (ObjDesc, RetBuffer); 620 621 /* On exit, we must delete the object returned by EvaluateObject */ 622 623 AcpiUtRemoveReference (ObjDesc); 624 return_ACPI_STATUS (Status); 625 } 626 627 628 /******************************************************************************* 629 * 630 * FUNCTION: AcpiRsGetCrsMethodData 631 * 632 * PARAMETERS: Node - Device node 633 * RetBuffer - Pointer to a buffer structure for the 634 * results 635 * 636 * RETURN: Status 637 * 638 * DESCRIPTION: This function is called to get the _CRS value of an object 639 * contained in an object specified by the handle passed in 640 * 641 * If the function fails an appropriate status will be returned 642 * and the contents of the callers buffer is undefined. 643 * 644 ******************************************************************************/ 645 646 ACPI_STATUS 647 AcpiRsGetCrsMethodData ( 648 ACPI_NAMESPACE_NODE *Node, 649 ACPI_BUFFER *RetBuffer) 650 { 651 ACPI_OPERAND_OBJECT *ObjDesc; 652 ACPI_STATUS Status; 653 654 655 ACPI_FUNCTION_TRACE (RsGetCrsMethodData); 656 657 658 /* Parameters guaranteed valid by caller */ 659 660 /* Execute the method, no parameters */ 661 662 Status = AcpiUtEvaluateObject ( 663 Node, METHOD_NAME__CRS, ACPI_BTYPE_BUFFER, &ObjDesc); 664 if (ACPI_FAILURE (Status)) 665 { 666 return_ACPI_STATUS (Status); 667 } 668 669 /* 670 * Make the call to create a resource linked list from the 671 * byte stream buffer that comes back from the _CRS method 672 * execution. 673 */ 674 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); 675 676 /* On exit, we must delete the object returned by evaluateObject */ 677 678 AcpiUtRemoveReference (ObjDesc); 679 return_ACPI_STATUS (Status); 680 } 681 682 683 /******************************************************************************* 684 * 685 * FUNCTION: AcpiRsGetPrsMethodData 686 * 687 * PARAMETERS: Node - Device node 688 * RetBuffer - Pointer to a buffer structure for the 689 * results 690 * 691 * RETURN: Status 692 * 693 * DESCRIPTION: This function is called to get the _PRS value of an object 694 * contained in an object specified by the handle passed in 695 * 696 * If the function fails an appropriate status will be returned 697 * and the contents of the callers buffer is undefined. 698 * 699 ******************************************************************************/ 700 701 ACPI_STATUS 702 AcpiRsGetPrsMethodData ( 703 ACPI_NAMESPACE_NODE *Node, 704 ACPI_BUFFER *RetBuffer) 705 { 706 ACPI_OPERAND_OBJECT *ObjDesc; 707 ACPI_STATUS Status; 708 709 710 ACPI_FUNCTION_TRACE (RsGetPrsMethodData); 711 712 713 /* Parameters guaranteed valid by caller */ 714 715 /* Execute the method, no parameters */ 716 717 Status = AcpiUtEvaluateObject ( 718 Node, METHOD_NAME__PRS, ACPI_BTYPE_BUFFER, &ObjDesc); 719 if (ACPI_FAILURE (Status)) 720 { 721 return_ACPI_STATUS (Status); 722 } 723 724 /* 725 * Make the call to create a resource linked list from the 726 * byte stream buffer that comes back from the _CRS method 727 * execution. 728 */ 729 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); 730 731 /* On exit, we must delete the object returned by evaluateObject */ 732 733 AcpiUtRemoveReference (ObjDesc); 734 return_ACPI_STATUS (Status); 735 } 736 737 738 /******************************************************************************* 739 * 740 * FUNCTION: AcpiRsGetAeiMethodData 741 * 742 * PARAMETERS: Node - Device node 743 * RetBuffer - Pointer to a buffer structure for the 744 * results 745 * 746 * RETURN: Status 747 * 748 * DESCRIPTION: This function is called to get the _AEI value of an object 749 * contained in an object specified by the handle passed in 750 * 751 * If the function fails an appropriate status will be returned 752 * and the contents of the callers buffer is undefined. 753 * 754 ******************************************************************************/ 755 756 ACPI_STATUS 757 AcpiRsGetAeiMethodData ( 758 ACPI_NAMESPACE_NODE *Node, 759 ACPI_BUFFER *RetBuffer) 760 { 761 ACPI_OPERAND_OBJECT *ObjDesc; 762 ACPI_STATUS Status; 763 764 765 ACPI_FUNCTION_TRACE (RsGetAeiMethodData); 766 767 768 /* Parameters guaranteed valid by caller */ 769 770 /* Execute the method, no parameters */ 771 772 Status = AcpiUtEvaluateObject ( 773 Node, METHOD_NAME__AEI, ACPI_BTYPE_BUFFER, &ObjDesc); 774 if (ACPI_FAILURE (Status)) 775 { 776 return_ACPI_STATUS (Status); 777 } 778 779 /* 780 * Make the call to create a resource linked list from the 781 * byte stream buffer that comes back from the _CRS method 782 * execution. 783 */ 784 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); 785 786 /* On exit, we must delete the object returned by evaluateObject */ 787 788 AcpiUtRemoveReference (ObjDesc); 789 return_ACPI_STATUS (Status); 790 } 791 792 793 /******************************************************************************* 794 * 795 * FUNCTION: AcpiRsGetMethodData 796 * 797 * PARAMETERS: Handle - Handle to the containing object 798 * Path - Path to method, relative to Handle 799 * RetBuffer - Pointer to a buffer structure for the 800 * results 801 * 802 * RETURN: Status 803 * 804 * DESCRIPTION: This function is called to get the _CRS or _PRS value of an 805 * object contained in an object specified by the handle passed in 806 * 807 * If the function fails an appropriate status will be returned 808 * and the contents of the callers buffer is undefined. 809 * 810 ******************************************************************************/ 811 812 ACPI_STATUS 813 AcpiRsGetMethodData ( 814 ACPI_HANDLE Handle, 815 const char *Path, 816 ACPI_BUFFER *RetBuffer) 817 { 818 ACPI_OPERAND_OBJECT *ObjDesc; 819 ACPI_STATUS Status; 820 821 822 ACPI_FUNCTION_TRACE (RsGetMethodData); 823 824 825 /* Parameters guaranteed valid by caller */ 826 827 /* Execute the method, no parameters */ 828 829 Status = AcpiUtEvaluateObject ( 830 ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Handle), 831 Path, ACPI_BTYPE_BUFFER, &ObjDesc); 832 if (ACPI_FAILURE (Status)) 833 { 834 return_ACPI_STATUS (Status); 835 } 836 837 /* 838 * Make the call to create a resource linked list from the 839 * byte stream buffer that comes back from the method 840 * execution. 841 */ 842 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); 843 844 /* On exit, we must delete the object returned by EvaluateObject */ 845 846 AcpiUtRemoveReference (ObjDesc); 847 return_ACPI_STATUS (Status); 848 } 849 850 851 /******************************************************************************* 852 * 853 * FUNCTION: AcpiRsSetSrsMethodData 854 * 855 * PARAMETERS: Node - Device node 856 * InBuffer - Pointer to a buffer structure of the 857 * parameter 858 * 859 * RETURN: Status 860 * 861 * DESCRIPTION: This function is called to set the _SRS of an object contained 862 * in an object specified by the handle passed in 863 * 864 * If the function fails an appropriate status will be returned 865 * and the contents of the callers buffer is undefined. 866 * 867 * Note: Parameters guaranteed valid by caller 868 * 869 ******************************************************************************/ 870 871 ACPI_STATUS 872 AcpiRsSetSrsMethodData ( 873 ACPI_NAMESPACE_NODE *Node, 874 ACPI_BUFFER *InBuffer) 875 { 876 ACPI_EVALUATE_INFO *Info; 877 ACPI_OPERAND_OBJECT *Args[2]; 878 ACPI_STATUS Status; 879 ACPI_BUFFER Buffer; 880 881 882 ACPI_FUNCTION_TRACE (RsSetSrsMethodData); 883 884 885 /* Allocate and initialize the evaluation information block */ 886 887 Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); 888 if (!Info) 889 { 890 return_ACPI_STATUS (AE_NO_MEMORY); 891 } 892 893 Info->PrefixNode = Node; 894 Info->RelativePathname = METHOD_NAME__SRS; 895 Info->Parameters = Args; 896 Info->Flags = ACPI_IGNORE_RETURN_VALUE; 897 898 /* 899 * The InBuffer parameter will point to a linked list of 900 * resource parameters. It needs to be formatted into a 901 * byte stream to be sent in as an input parameter to _SRS 902 * 903 * Convert the linked list into a byte stream 904 */ 905 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 906 Status = AcpiRsCreateAmlResources (InBuffer, &Buffer); 907 if (ACPI_FAILURE (Status)) 908 { 909 goto Cleanup; 910 } 911 912 /* Create and initialize the method parameter object */ 913 914 Args[0] = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); 915 if (!Args[0]) 916 { 917 /* 918 * Must free the buffer allocated above (otherwise it is freed 919 * later) 920 */ 921 ACPI_FREE (Buffer.Pointer); 922 Status = AE_NO_MEMORY; 923 goto Cleanup; 924 } 925 926 Args[0]->Buffer.Length = (UINT32) Buffer.Length; 927 Args[0]->Buffer.Pointer = Buffer.Pointer; 928 Args[0]->Common.Flags = AOPOBJ_DATA_VALID; 929 Args[1] = NULL; 930 931 /* Execute the method, no return value is expected */ 932 933 Status = AcpiNsEvaluate (Info); 934 935 /* Clean up and return the status from AcpiNsEvaluate */ 936 937 AcpiUtRemoveReference (Args[0]); 938 939 Cleanup: 940 ACPI_FREE (Info); 941 return_ACPI_STATUS (Status); 942 } 943