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 - 2013, 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 117 #define __RSUTILS_C__ 118 119 #include "acpi.h" 120 #include "accommon.h" 121 #include "acnamesp.h" 122 #include "acresrc.h" 123 124 125 #define _COMPONENT ACPI_RESOURCES 126 ACPI_MODULE_NAME ("rsutils") 127 128 129 /******************************************************************************* 130 * 131 * FUNCTION: AcpiRsDecodeBitmask 132 * 133 * PARAMETERS: Mask - Bitmask to decode 134 * List - Where the converted list is returned 135 * 136 * RETURN: Count of bits set (length of list) 137 * 138 * DESCRIPTION: Convert a bit mask into a list of values 139 * 140 ******************************************************************************/ 141 142 UINT8 143 AcpiRsDecodeBitmask ( 144 UINT16 Mask, 145 UINT8 *List) 146 { 147 UINT8 i; 148 UINT8 BitCount; 149 150 151 ACPI_FUNCTION_ENTRY (); 152 153 154 /* Decode the mask bits */ 155 156 for (i = 0, BitCount = 0; Mask; i++) 157 { 158 if (Mask & 0x0001) 159 { 160 List[BitCount] = i; 161 BitCount++; 162 } 163 164 Mask >>= 1; 165 } 166 167 return (BitCount); 168 } 169 170 171 /******************************************************************************* 172 * 173 * FUNCTION: AcpiRsEncodeBitmask 174 * 175 * PARAMETERS: List - List of values to encode 176 * Count - Length of list 177 * 178 * RETURN: Encoded bitmask 179 * 180 * DESCRIPTION: Convert a list of values to an encoded bitmask 181 * 182 ******************************************************************************/ 183 184 UINT16 185 AcpiRsEncodeBitmask ( 186 UINT8 *List, 187 UINT8 Count) 188 { 189 UINT32 i; 190 UINT16 Mask; 191 192 193 ACPI_FUNCTION_ENTRY (); 194 195 196 /* Encode the list into a single bitmask */ 197 198 for (i = 0, Mask = 0; i < Count; i++) 199 { 200 Mask |= (0x1 << List[i]); 201 } 202 203 return (Mask); 204 } 205 206 207 /******************************************************************************* 208 * 209 * FUNCTION: AcpiRsMoveData 210 * 211 * PARAMETERS: Destination - Pointer to the destination descriptor 212 * Source - Pointer to the source descriptor 213 * ItemCount - How many items to move 214 * MoveType - Byte width 215 * 216 * RETURN: None 217 * 218 * DESCRIPTION: Move multiple data items from one descriptor to another. Handles 219 * alignment issues and endian issues if necessary, as configured 220 * via the ACPI_MOVE_* macros. (This is why a memcpy is not used) 221 * 222 ******************************************************************************/ 223 224 void 225 AcpiRsMoveData ( 226 void *Destination, 227 void *Source, 228 UINT16 ItemCount, 229 UINT8 MoveType) 230 { 231 UINT32 i; 232 233 234 ACPI_FUNCTION_ENTRY (); 235 236 237 /* One move per item */ 238 239 for (i = 0; i < ItemCount; i++) 240 { 241 switch (MoveType) 242 { 243 /* 244 * For the 8-bit case, we can perform the move all at once 245 * since there are no alignment or endian issues 246 */ 247 case ACPI_RSC_MOVE8: 248 case ACPI_RSC_MOVE_GPIO_RES: 249 case ACPI_RSC_MOVE_SERIAL_VEN: 250 case ACPI_RSC_MOVE_SERIAL_RES: 251 252 ACPI_MEMCPY (Destination, Source, ItemCount); 253 return; 254 255 /* 256 * 16-, 32-, and 64-bit cases must use the move macros that perform 257 * endian conversion and/or accommodate hardware that cannot perform 258 * misaligned memory transfers 259 */ 260 case ACPI_RSC_MOVE16: 261 case ACPI_RSC_MOVE_GPIO_PIN: 262 263 ACPI_MOVE_16_TO_16 (&ACPI_CAST_PTR (UINT16, Destination)[i], 264 &ACPI_CAST_PTR (UINT16, Source)[i]); 265 break; 266 267 case ACPI_RSC_MOVE32: 268 269 ACPI_MOVE_32_TO_32 (&ACPI_CAST_PTR (UINT32, Destination)[i], 270 &ACPI_CAST_PTR (UINT32, Source)[i]); 271 break; 272 273 case ACPI_RSC_MOVE64: 274 275 ACPI_MOVE_64_TO_64 (&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 (&Aml->LargeHeader.ResourceLength, &ResourceLength); 327 } 328 else 329 { 330 /* Small descriptor -- bits 2:0 of byte 0 contain the length */ 331 332 Aml->SmallHeader.DescriptorType = (UINT8) 333 334 /* Clear any existing length, preserving descriptor type bits */ 335 336 ((Aml->SmallHeader.DescriptorType & ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK) 337 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 than 457 * 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 (char, ResourceSource, 476 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) ACPI_STRLEN ( 487 ACPI_CAST_PTR (char, &AmlResourceSource[1])) + 1; 488 TotalLength = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (TotalLength); 489 490 ACPI_MEMSET (ResourceSource->StringPtr, 0, TotalLength); 491 492 /* Copy the ResourceSource string to the destination */ 493 494 ResourceSource->StringLength = AcpiRsStrcpy (ResourceSource->StringPtr, 495 ACPI_CAST_PTR (char, &AmlResourceSource[1])); 496 497 return ((ACPI_RS_LENGTH) TotalLength); 498 } 499 500 /* ResourceSource is not present */ 501 502 ResourceSource->Index = 0; 503 ResourceSource->StringLength = 0; 504 ResourceSource->StringPtr = NULL; 505 return (0); 506 } 507 508 509 /******************************************************************************* 510 * 511 * FUNCTION: AcpiRsSetResourceSource 512 * 513 * PARAMETERS: Aml - Pointer to the raw AML descriptor 514 * MinimumLength - Minimum length of the descriptor (minus 515 * any optional fields) 516 * ResourceSource - Internal ResourceSource 517 518 * 519 * RETURN: Total length of the AML descriptor 520 * 521 * DESCRIPTION: Convert an optional ResourceSource from internal format to a 522 * raw AML resource descriptor 523 * 524 ******************************************************************************/ 525 526 ACPI_RSDESC_SIZE 527 AcpiRsSetResourceSource ( 528 AML_RESOURCE *Aml, 529 ACPI_RS_LENGTH MinimumLength, 530 ACPI_RESOURCE_SOURCE *ResourceSource) 531 { 532 UINT8 *AmlResourceSource; 533 ACPI_RSDESC_SIZE DescriptorLength; 534 535 536 ACPI_FUNCTION_ENTRY (); 537 538 539 DescriptorLength = MinimumLength; 540 541 /* Non-zero string length indicates presence of a ResourceSource */ 542 543 if (ResourceSource->StringLength) 544 { 545 /* Point to the end of the AML descriptor */ 546 547 AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength); 548 549 /* Copy the ResourceSourceIndex */ 550 551 AmlResourceSource[0] = (UINT8) ResourceSource->Index; 552 553 /* Copy the ResourceSource string */ 554 555 ACPI_STRCPY (ACPI_CAST_PTR (char, &AmlResourceSource[1]), 556 ResourceSource->StringPtr); 557 558 /* 559 * Add the length of the string (+ 1 for null terminator) to the 560 * final descriptor length 561 */ 562 DescriptorLength += ((ACPI_RSDESC_SIZE) ResourceSource->StringLength + 1); 563 } 564 565 /* Return the new total length of the AML descriptor */ 566 567 return (DescriptorLength); 568 } 569 570 571 /******************************************************************************* 572 * 573 * FUNCTION: AcpiRsGetPrtMethodData 574 * 575 * PARAMETERS: Node - Device node 576 * RetBuffer - Pointer to a buffer structure for the 577 * results 578 * 579 * RETURN: Status 580 * 581 * DESCRIPTION: This function is called to get the _PRT value of an object 582 * contained in an object specified by the handle passed in 583 * 584 * If the function fails an appropriate status will be returned 585 * and the contents of the callers buffer is undefined. 586 * 587 ******************************************************************************/ 588 589 ACPI_STATUS 590 AcpiRsGetPrtMethodData ( 591 ACPI_NAMESPACE_NODE *Node, 592 ACPI_BUFFER *RetBuffer) 593 { 594 ACPI_OPERAND_OBJECT *ObjDesc; 595 ACPI_STATUS Status; 596 597 598 ACPI_FUNCTION_TRACE (RsGetPrtMethodData); 599 600 601 /* Parameters guaranteed valid by caller */ 602 603 /* Execute the method, no parameters */ 604 605 Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRT, 606 ACPI_BTYPE_PACKAGE, &ObjDesc); 607 if (ACPI_FAILURE (Status)) 608 { 609 return_ACPI_STATUS (Status); 610 } 611 612 /* 613 * Create a resource linked list from the byte stream buffer that comes 614 * back from the _CRS method execution. 615 */ 616 Status = AcpiRsCreatePciRoutingTable (ObjDesc, RetBuffer); 617 618 /* On exit, we must delete the object returned by EvaluateObject */ 619 620 AcpiUtRemoveReference (ObjDesc); 621 return_ACPI_STATUS (Status); 622 } 623 624 625 /******************************************************************************* 626 * 627 * FUNCTION: AcpiRsGetCrsMethodData 628 * 629 * PARAMETERS: Node - Device node 630 * RetBuffer - Pointer to a buffer structure for the 631 * results 632 * 633 * RETURN: Status 634 * 635 * DESCRIPTION: This function is called to get the _CRS value of an object 636 * contained in an object specified by the handle passed in 637 * 638 * If the function fails an appropriate status will be returned 639 * and the contents of the callers buffer is undefined. 640 * 641 ******************************************************************************/ 642 643 ACPI_STATUS 644 AcpiRsGetCrsMethodData ( 645 ACPI_NAMESPACE_NODE *Node, 646 ACPI_BUFFER *RetBuffer) 647 { 648 ACPI_OPERAND_OBJECT *ObjDesc; 649 ACPI_STATUS Status; 650 651 652 ACPI_FUNCTION_TRACE (RsGetCrsMethodData); 653 654 655 /* Parameters guaranteed valid by caller */ 656 657 /* Execute the method, no parameters */ 658 659 Status = AcpiUtEvaluateObject (Node, METHOD_NAME__CRS, 660 ACPI_BTYPE_BUFFER, &ObjDesc); 661 if (ACPI_FAILURE (Status)) 662 { 663 return_ACPI_STATUS (Status); 664 } 665 666 /* 667 * Make the call to create a resource linked list from the 668 * byte stream buffer that comes back from the _CRS method 669 * execution. 670 */ 671 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); 672 673 /* On exit, we must delete the object returned by evaluateObject */ 674 675 AcpiUtRemoveReference (ObjDesc); 676 return_ACPI_STATUS (Status); 677 } 678 679 680 /******************************************************************************* 681 * 682 * FUNCTION: AcpiRsGetPrsMethodData 683 * 684 * PARAMETERS: Node - Device node 685 * RetBuffer - Pointer to a buffer structure for the 686 * results 687 * 688 * RETURN: Status 689 * 690 * DESCRIPTION: This function is called to get the _PRS value of an object 691 * contained in an object specified by the handle passed in 692 * 693 * If the function fails an appropriate status will be returned 694 * and the contents of the callers buffer is undefined. 695 * 696 ******************************************************************************/ 697 698 ACPI_STATUS 699 AcpiRsGetPrsMethodData ( 700 ACPI_NAMESPACE_NODE *Node, 701 ACPI_BUFFER *RetBuffer) 702 { 703 ACPI_OPERAND_OBJECT *ObjDesc; 704 ACPI_STATUS Status; 705 706 707 ACPI_FUNCTION_TRACE (RsGetPrsMethodData); 708 709 710 /* Parameters guaranteed valid by caller */ 711 712 /* Execute the method, no parameters */ 713 714 Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRS, 715 ACPI_BTYPE_BUFFER, &ObjDesc); 716 if (ACPI_FAILURE (Status)) 717 { 718 return_ACPI_STATUS (Status); 719 } 720 721 /* 722 * Make the call to create a resource linked list from the 723 * byte stream buffer that comes back from the _CRS method 724 * execution. 725 */ 726 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); 727 728 /* On exit, we must delete the object returned by evaluateObject */ 729 730 AcpiUtRemoveReference (ObjDesc); 731 return_ACPI_STATUS (Status); 732 } 733 734 735 /******************************************************************************* 736 * 737 * FUNCTION: AcpiRsGetAeiMethodData 738 * 739 * PARAMETERS: Node - Device node 740 * RetBuffer - Pointer to a buffer structure for the 741 * results 742 * 743 * RETURN: Status 744 * 745 * DESCRIPTION: This function is called to get the _AEI value of an object 746 * contained in an object specified by the handle passed in 747 * 748 * If the function fails an appropriate status will be returned 749 * and the contents of the callers buffer is undefined. 750 * 751 ******************************************************************************/ 752 753 ACPI_STATUS 754 AcpiRsGetAeiMethodData ( 755 ACPI_NAMESPACE_NODE *Node, 756 ACPI_BUFFER *RetBuffer) 757 { 758 ACPI_OPERAND_OBJECT *ObjDesc; 759 ACPI_STATUS Status; 760 761 762 ACPI_FUNCTION_TRACE (RsGetAeiMethodData); 763 764 765 /* Parameters guaranteed valid by caller */ 766 767 /* Execute the method, no parameters */ 768 769 Status = AcpiUtEvaluateObject (Node, METHOD_NAME__AEI, 770 ACPI_BTYPE_BUFFER, &ObjDesc); 771 if (ACPI_FAILURE (Status)) 772 { 773 return_ACPI_STATUS (Status); 774 } 775 776 /* 777 * Make the call to create a resource linked list from the 778 * byte stream buffer that comes back from the _CRS method 779 * execution. 780 */ 781 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); 782 783 /* On exit, we must delete the object returned by evaluateObject */ 784 785 AcpiUtRemoveReference (ObjDesc); 786 return_ACPI_STATUS (Status); 787 } 788 789 790 /******************************************************************************* 791 * 792 * FUNCTION: AcpiRsGetMethodData 793 * 794 * PARAMETERS: Handle - Handle to the containing object 795 * Path - Path to method, relative to Handle 796 * RetBuffer - Pointer to a buffer structure for the 797 * results 798 * 799 * RETURN: Status 800 * 801 * DESCRIPTION: This function is called to get the _CRS or _PRS value of an 802 * object contained in an object specified by the handle passed in 803 * 804 * If the function fails an appropriate status will be returned 805 * and the contents of the callers buffer is undefined. 806 * 807 ******************************************************************************/ 808 809 ACPI_STATUS 810 AcpiRsGetMethodData ( 811 ACPI_HANDLE Handle, 812 char *Path, 813 ACPI_BUFFER *RetBuffer) 814 { 815 ACPI_OPERAND_OBJECT *ObjDesc; 816 ACPI_STATUS Status; 817 818 819 ACPI_FUNCTION_TRACE (RsGetMethodData); 820 821 822 /* Parameters guaranteed valid by caller */ 823 824 /* Execute the method, no parameters */ 825 826 Status = AcpiUtEvaluateObject (ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Handle), 827 Path, ACPI_BTYPE_BUFFER, &ObjDesc); 828 if (ACPI_FAILURE (Status)) 829 { 830 return_ACPI_STATUS (Status); 831 } 832 833 /* 834 * Make the call to create a resource linked list from the 835 * byte stream buffer that comes back from the method 836 * execution. 837 */ 838 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); 839 840 /* On exit, we must delete the object returned by EvaluateObject */ 841 842 AcpiUtRemoveReference (ObjDesc); 843 return_ACPI_STATUS (Status); 844 } 845 846 847 /******************************************************************************* 848 * 849 * FUNCTION: AcpiRsSetSrsMethodData 850 * 851 * PARAMETERS: Node - Device node 852 * InBuffer - Pointer to a buffer structure of the 853 * parameter 854 * 855 * RETURN: Status 856 * 857 * DESCRIPTION: This function is called to set the _SRS of an object contained 858 * in an object specified by the handle passed in 859 * 860 * If the function fails an appropriate status will be returned 861 * and the contents of the callers buffer is undefined. 862 * 863 * Note: Parameters guaranteed valid by caller 864 * 865 ******************************************************************************/ 866 867 ACPI_STATUS 868 AcpiRsSetSrsMethodData ( 869 ACPI_NAMESPACE_NODE *Node, 870 ACPI_BUFFER *InBuffer) 871 { 872 ACPI_EVALUATE_INFO *Info; 873 ACPI_OPERAND_OBJECT *Args[2]; 874 ACPI_STATUS Status; 875 ACPI_BUFFER Buffer; 876 877 878 ACPI_FUNCTION_TRACE (RsSetSrsMethodData); 879 880 881 /* Allocate and initialize the evaluation information block */ 882 883 Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); 884 if (!Info) 885 { 886 return_ACPI_STATUS (AE_NO_MEMORY); 887 } 888 889 Info->PrefixNode = Node; 890 Info->RelativePathname = METHOD_NAME__SRS; 891 Info->Parameters = Args; 892 Info->Flags = ACPI_IGNORE_RETURN_VALUE; 893 894 /* 895 * The InBuffer parameter will point to a linked list of 896 * resource parameters. It needs to be formatted into a 897 * byte stream to be sent in as an input parameter to _SRS 898 * 899 * Convert the linked list into a byte stream 900 */ 901 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 902 Status = AcpiRsCreateAmlResources (InBuffer->Pointer, &Buffer); 903 if (ACPI_FAILURE (Status)) 904 { 905 goto Cleanup; 906 } 907 908 /* Create and initialize the method parameter object */ 909 910 Args[0] = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); 911 if (!Args[0]) 912 { 913 /* 914 * Must free the buffer allocated above (otherwise it is freed 915 * later) 916 */ 917 ACPI_FREE (Buffer.Pointer); 918 Status = AE_NO_MEMORY; 919 goto Cleanup; 920 } 921 922 Args[0]->Buffer.Length = (UINT32) Buffer.Length; 923 Args[0]->Buffer.Pointer = Buffer.Pointer; 924 Args[0]->Common.Flags = AOPOBJ_DATA_VALID; 925 Args[1] = NULL; 926 927 /* Execute the method, no return value is expected */ 928 929 Status = AcpiNsEvaluate (Info); 930 931 /* Clean up and return the status from AcpiNsEvaluate */ 932 933 AcpiUtRemoveReference (Args[0]); 934 935 Cleanup: 936 ACPI_FREE (Info); 937 return_ACPI_STATUS (Status); 938 } 939