1 /******************************************************************************* 2 * 3 * Module Name: rsutils - Utilities for the resource manager 4 * 5 ******************************************************************************/ 6 7 /* 8 * Copyright (C) 2000 - 2014, Intel Corp. 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions, and the following disclaimer, 16 * without modification. 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18 * substantially similar to the "NO WARRANTY" disclaimer below 19 * ("Disclaimer") and any redistribution must be conditioned upon 20 * including a substantially similar Disclaimer requirement for further 21 * binary redistribution. 22 * 3. Neither the names of the above-listed copyright holders nor the names 23 * of any contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * Alternatively, this software may be distributed under the terms of the 27 * GNU General Public License ("GPL") version 2 as published by the Free 28 * Software Foundation. 29 * 30 * NO WARRANTY 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41 * POSSIBILITY OF SUCH DAMAGES. 42 */ 43 44 #define __RSUTILS_C__ 45 46 #include <contrib/dev/acpica/include/acpi.h> 47 #include <contrib/dev/acpica/include/accommon.h> 48 #include <contrib/dev/acpica/include/acnamesp.h> 49 #include <contrib/dev/acpica/include/acresrc.h> 50 51 52 #define _COMPONENT ACPI_RESOURCES 53 ACPI_MODULE_NAME ("rsutils") 54 55 56 /******************************************************************************* 57 * 58 * FUNCTION: AcpiRsDecodeBitmask 59 * 60 * PARAMETERS: Mask - Bitmask to decode 61 * List - Where the converted list is returned 62 * 63 * RETURN: Count of bits set (length of list) 64 * 65 * DESCRIPTION: Convert a bit mask into a list of values 66 * 67 ******************************************************************************/ 68 69 UINT8 70 AcpiRsDecodeBitmask ( 71 UINT16 Mask, 72 UINT8 *List) 73 { 74 UINT8 i; 75 UINT8 BitCount; 76 77 78 ACPI_FUNCTION_ENTRY (); 79 80 81 /* Decode the mask bits */ 82 83 for (i = 0, BitCount = 0; Mask; i++) 84 { 85 if (Mask & 0x0001) 86 { 87 List[BitCount] = i; 88 BitCount++; 89 } 90 91 Mask >>= 1; 92 } 93 94 return (BitCount); 95 } 96 97 98 /******************************************************************************* 99 * 100 * FUNCTION: AcpiRsEncodeBitmask 101 * 102 * PARAMETERS: List - List of values to encode 103 * Count - Length of list 104 * 105 * RETURN: Encoded bitmask 106 * 107 * DESCRIPTION: Convert a list of values to an encoded bitmask 108 * 109 ******************************************************************************/ 110 111 UINT16 112 AcpiRsEncodeBitmask ( 113 UINT8 *List, 114 UINT8 Count) 115 { 116 UINT32 i; 117 UINT16 Mask; 118 119 120 ACPI_FUNCTION_ENTRY (); 121 122 123 /* Encode the list into a single bitmask */ 124 125 for (i = 0, Mask = 0; i < Count; i++) 126 { 127 Mask |= (0x1 << List[i]); 128 } 129 130 return (Mask); 131 } 132 133 134 /******************************************************************************* 135 * 136 * FUNCTION: AcpiRsMoveData 137 * 138 * PARAMETERS: Destination - Pointer to the destination descriptor 139 * Source - Pointer to the source descriptor 140 * ItemCount - How many items to move 141 * MoveType - Byte width 142 * 143 * RETURN: None 144 * 145 * DESCRIPTION: Move multiple data items from one descriptor to another. Handles 146 * alignment issues and endian issues if necessary, as configured 147 * via the ACPI_MOVE_* macros. (This is why a memcpy is not used) 148 * 149 ******************************************************************************/ 150 151 void 152 AcpiRsMoveData ( 153 void *Destination, 154 void *Source, 155 UINT16 ItemCount, 156 UINT8 MoveType) 157 { 158 UINT32 i; 159 160 161 ACPI_FUNCTION_ENTRY (); 162 163 164 /* One move per item */ 165 166 for (i = 0; i < ItemCount; i++) 167 { 168 switch (MoveType) 169 { 170 /* 171 * For the 8-bit case, we can perform the move all at once 172 * since there are no alignment or endian issues 173 */ 174 case ACPI_RSC_MOVE8: 175 case ACPI_RSC_MOVE_GPIO_RES: 176 case ACPI_RSC_MOVE_SERIAL_VEN: 177 case ACPI_RSC_MOVE_SERIAL_RES: 178 179 ACPI_MEMCPY (Destination, Source, ItemCount); 180 return; 181 182 /* 183 * 16-, 32-, and 64-bit cases must use the move macros that perform 184 * endian conversion and/or accommodate hardware that cannot perform 185 * misaligned memory transfers 186 */ 187 case ACPI_RSC_MOVE16: 188 case ACPI_RSC_MOVE_GPIO_PIN: 189 190 ACPI_MOVE_16_TO_16 (&ACPI_CAST_PTR (UINT16, Destination)[i], 191 &ACPI_CAST_PTR (UINT16, Source)[i]); 192 break; 193 194 case ACPI_RSC_MOVE32: 195 196 ACPI_MOVE_32_TO_32 (&ACPI_CAST_PTR (UINT32, Destination)[i], 197 &ACPI_CAST_PTR (UINT32, Source)[i]); 198 break; 199 200 case ACPI_RSC_MOVE64: 201 202 ACPI_MOVE_64_TO_64 (&ACPI_CAST_PTR (UINT64, Destination)[i], 203 &ACPI_CAST_PTR (UINT64, Source)[i]); 204 break; 205 206 default: 207 208 return; 209 } 210 } 211 } 212 213 214 /******************************************************************************* 215 * 216 * FUNCTION: AcpiRsSetResourceLength 217 * 218 * PARAMETERS: TotalLength - Length of the AML descriptor, including 219 * the header and length fields. 220 * Aml - Pointer to the raw AML descriptor 221 * 222 * RETURN: None 223 * 224 * DESCRIPTION: Set the ResourceLength field of an AML 225 * resource descriptor, both Large and Small descriptors are 226 * supported automatically. Note: Descriptor Type field must 227 * be valid. 228 * 229 ******************************************************************************/ 230 231 void 232 AcpiRsSetResourceLength ( 233 ACPI_RSDESC_SIZE TotalLength, 234 AML_RESOURCE *Aml) 235 { 236 ACPI_RS_LENGTH ResourceLength; 237 238 239 ACPI_FUNCTION_ENTRY (); 240 241 242 /* Length is the total descriptor length minus the header length */ 243 244 ResourceLength = (ACPI_RS_LENGTH) 245 (TotalLength - AcpiUtGetResourceHeaderLength (Aml)); 246 247 /* Length is stored differently for large and small descriptors */ 248 249 if (Aml->SmallHeader.DescriptorType & ACPI_RESOURCE_NAME_LARGE) 250 { 251 /* Large descriptor -- bytes 1-2 contain the 16-bit length */ 252 253 ACPI_MOVE_16_TO_16 (&Aml->LargeHeader.ResourceLength, &ResourceLength); 254 } 255 else 256 { 257 /* Small descriptor -- bits 2:0 of byte 0 contain the length */ 258 259 Aml->SmallHeader.DescriptorType = (UINT8) 260 261 /* Clear any existing length, preserving descriptor type bits */ 262 263 ((Aml->SmallHeader.DescriptorType & ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK) 264 265 | ResourceLength); 266 } 267 } 268 269 270 /******************************************************************************* 271 * 272 * FUNCTION: AcpiRsSetResourceHeader 273 * 274 * PARAMETERS: DescriptorType - Byte to be inserted as the type 275 * TotalLength - Length of the AML descriptor, including 276 * the header and length fields. 277 * Aml - Pointer to the raw AML descriptor 278 * 279 * RETURN: None 280 * 281 * DESCRIPTION: Set the DescriptorType and ResourceLength fields of an AML 282 * resource descriptor, both Large and Small descriptors are 283 * supported automatically 284 * 285 ******************************************************************************/ 286 287 void 288 AcpiRsSetResourceHeader ( 289 UINT8 DescriptorType, 290 ACPI_RSDESC_SIZE TotalLength, 291 AML_RESOURCE *Aml) 292 { 293 ACPI_FUNCTION_ENTRY (); 294 295 296 /* Set the Resource Type */ 297 298 Aml->SmallHeader.DescriptorType = DescriptorType; 299 300 /* Set the Resource Length */ 301 302 AcpiRsSetResourceLength (TotalLength, Aml); 303 } 304 305 306 /******************************************************************************* 307 * 308 * FUNCTION: AcpiRsStrcpy 309 * 310 * PARAMETERS: Destination - Pointer to the destination string 311 * Source - Pointer to the source string 312 * 313 * RETURN: String length, including NULL terminator 314 * 315 * DESCRIPTION: Local string copy that returns the string length, saving a 316 * strcpy followed by a strlen. 317 * 318 ******************************************************************************/ 319 320 static UINT16 321 AcpiRsStrcpy ( 322 char *Destination, 323 char *Source) 324 { 325 UINT16 i; 326 327 328 ACPI_FUNCTION_ENTRY (); 329 330 331 for (i = 0; Source[i]; i++) 332 { 333 Destination[i] = Source[i]; 334 } 335 336 Destination[i] = 0; 337 338 /* Return string length including the NULL terminator */ 339 340 return ((UINT16) (i + 1)); 341 } 342 343 344 /******************************************************************************* 345 * 346 * FUNCTION: AcpiRsGetResourceSource 347 * 348 * PARAMETERS: ResourceLength - Length field of the descriptor 349 * MinimumLength - Minimum length of the descriptor (minus 350 * any optional fields) 351 * ResourceSource - Where the ResourceSource is returned 352 * Aml - Pointer to the raw AML descriptor 353 * StringPtr - (optional) where to store the actual 354 * ResourceSource string 355 * 356 * RETURN: Length of the string plus NULL terminator, rounded up to native 357 * word boundary 358 * 359 * DESCRIPTION: Copy the optional ResourceSource data from a raw AML descriptor 360 * to an internal resource descriptor 361 * 362 ******************************************************************************/ 363 364 ACPI_RS_LENGTH 365 AcpiRsGetResourceSource ( 366 ACPI_RS_LENGTH ResourceLength, 367 ACPI_RS_LENGTH MinimumLength, 368 ACPI_RESOURCE_SOURCE *ResourceSource, 369 AML_RESOURCE *Aml, 370 char *StringPtr) 371 { 372 ACPI_RSDESC_SIZE TotalLength; 373 UINT8 *AmlResourceSource; 374 375 376 ACPI_FUNCTION_ENTRY (); 377 378 379 TotalLength = ResourceLength + sizeof (AML_RESOURCE_LARGE_HEADER); 380 AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength); 381 382 /* 383 * ResourceSource is present if the length of the descriptor is longer than 384 * the minimum length. 385 * 386 * Note: Some resource descriptors will have an additional null, so 387 * we add 1 to the minimum length. 388 */ 389 if (TotalLength > (ACPI_RSDESC_SIZE) (MinimumLength + 1)) 390 { 391 /* Get the ResourceSourceIndex */ 392 393 ResourceSource->Index = AmlResourceSource[0]; 394 395 ResourceSource->StringPtr = StringPtr; 396 if (!StringPtr) 397 { 398 /* 399 * String destination pointer is not specified; Set the String 400 * pointer to the end of the current ResourceSource structure. 401 */ 402 ResourceSource->StringPtr = ACPI_ADD_PTR (char, ResourceSource, 403 sizeof (ACPI_RESOURCE_SOURCE)); 404 } 405 406 /* 407 * In order for the Resource length to be a multiple of the native 408 * word, calculate the length of the string (+1 for NULL terminator) 409 * and expand to the next word multiple. 410 * 411 * Zero the entire area of the buffer. 412 */ 413 TotalLength = (UINT32) ACPI_STRLEN ( 414 ACPI_CAST_PTR (char, &AmlResourceSource[1])) + 1; 415 TotalLength = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (TotalLength); 416 417 ACPI_MEMSET (ResourceSource->StringPtr, 0, TotalLength); 418 419 /* Copy the ResourceSource string to the destination */ 420 421 ResourceSource->StringLength = AcpiRsStrcpy (ResourceSource->StringPtr, 422 ACPI_CAST_PTR (char, &AmlResourceSource[1])); 423 424 return ((ACPI_RS_LENGTH) TotalLength); 425 } 426 427 /* ResourceSource is not present */ 428 429 ResourceSource->Index = 0; 430 ResourceSource->StringLength = 0; 431 ResourceSource->StringPtr = NULL; 432 return (0); 433 } 434 435 436 /******************************************************************************* 437 * 438 * FUNCTION: AcpiRsSetResourceSource 439 * 440 * PARAMETERS: Aml - Pointer to the raw AML descriptor 441 * MinimumLength - Minimum length of the descriptor (minus 442 * any optional fields) 443 * ResourceSource - Internal ResourceSource 444 445 * 446 * RETURN: Total length of the AML descriptor 447 * 448 * DESCRIPTION: Convert an optional ResourceSource from internal format to a 449 * raw AML resource descriptor 450 * 451 ******************************************************************************/ 452 453 ACPI_RSDESC_SIZE 454 AcpiRsSetResourceSource ( 455 AML_RESOURCE *Aml, 456 ACPI_RS_LENGTH MinimumLength, 457 ACPI_RESOURCE_SOURCE *ResourceSource) 458 { 459 UINT8 *AmlResourceSource; 460 ACPI_RSDESC_SIZE DescriptorLength; 461 462 463 ACPI_FUNCTION_ENTRY (); 464 465 466 DescriptorLength = MinimumLength; 467 468 /* Non-zero string length indicates presence of a ResourceSource */ 469 470 if (ResourceSource->StringLength) 471 { 472 /* Point to the end of the AML descriptor */ 473 474 AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength); 475 476 /* Copy the ResourceSourceIndex */ 477 478 AmlResourceSource[0] = (UINT8) ResourceSource->Index; 479 480 /* Copy the ResourceSource string */ 481 482 ACPI_STRCPY (ACPI_CAST_PTR (char, &AmlResourceSource[1]), 483 ResourceSource->StringPtr); 484 485 /* 486 * Add the length of the string (+ 1 for null terminator) to the 487 * final descriptor length 488 */ 489 DescriptorLength += ((ACPI_RSDESC_SIZE) ResourceSource->StringLength + 1); 490 } 491 492 /* Return the new total length of the AML descriptor */ 493 494 return (DescriptorLength); 495 } 496 497 498 /******************************************************************************* 499 * 500 * FUNCTION: AcpiRsGetPrtMethodData 501 * 502 * PARAMETERS: Node - Device node 503 * RetBuffer - Pointer to a buffer structure for the 504 * results 505 * 506 * RETURN: Status 507 * 508 * DESCRIPTION: This function is called to get the _PRT value of an object 509 * contained in an object specified by the handle passed in 510 * 511 * If the function fails an appropriate status will be returned 512 * and the contents of the callers buffer is undefined. 513 * 514 ******************************************************************************/ 515 516 ACPI_STATUS 517 AcpiRsGetPrtMethodData ( 518 ACPI_NAMESPACE_NODE *Node, 519 ACPI_BUFFER *RetBuffer) 520 { 521 ACPI_OPERAND_OBJECT *ObjDesc; 522 ACPI_STATUS Status; 523 524 525 ACPI_FUNCTION_TRACE (RsGetPrtMethodData); 526 527 528 /* Parameters guaranteed valid by caller */ 529 530 /* Execute the method, no parameters */ 531 532 Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRT, 533 ACPI_BTYPE_PACKAGE, &ObjDesc); 534 if (ACPI_FAILURE (Status)) 535 { 536 return_ACPI_STATUS (Status); 537 } 538 539 /* 540 * Create a resource linked list from the byte stream buffer that comes 541 * back from the _CRS method execution. 542 */ 543 Status = AcpiRsCreatePciRoutingTable (ObjDesc, RetBuffer); 544 545 /* On exit, we must delete the object returned by EvaluateObject */ 546 547 AcpiUtRemoveReference (ObjDesc); 548 return_ACPI_STATUS (Status); 549 } 550 551 552 /******************************************************************************* 553 * 554 * FUNCTION: AcpiRsGetCrsMethodData 555 * 556 * PARAMETERS: Node - Device node 557 * RetBuffer - Pointer to a buffer structure for the 558 * results 559 * 560 * RETURN: Status 561 * 562 * DESCRIPTION: This function is called to get the _CRS value of an object 563 * contained in an object specified by the handle passed in 564 * 565 * If the function fails an appropriate status will be returned 566 * and the contents of the callers buffer is undefined. 567 * 568 ******************************************************************************/ 569 570 ACPI_STATUS 571 AcpiRsGetCrsMethodData ( 572 ACPI_NAMESPACE_NODE *Node, 573 ACPI_BUFFER *RetBuffer) 574 { 575 ACPI_OPERAND_OBJECT *ObjDesc; 576 ACPI_STATUS Status; 577 578 579 ACPI_FUNCTION_TRACE (RsGetCrsMethodData); 580 581 582 /* Parameters guaranteed valid by caller */ 583 584 /* Execute the method, no parameters */ 585 586 Status = AcpiUtEvaluateObject (Node, METHOD_NAME__CRS, 587 ACPI_BTYPE_BUFFER, &ObjDesc); 588 if (ACPI_FAILURE (Status)) 589 { 590 return_ACPI_STATUS (Status); 591 } 592 593 /* 594 * Make the call to create a resource linked list from the 595 * byte stream buffer that comes back from the _CRS method 596 * execution. 597 */ 598 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); 599 600 /* On exit, we must delete the object returned by evaluateObject */ 601 602 AcpiUtRemoveReference (ObjDesc); 603 return_ACPI_STATUS (Status); 604 } 605 606 607 /******************************************************************************* 608 * 609 * FUNCTION: AcpiRsGetPrsMethodData 610 * 611 * PARAMETERS: Node - Device node 612 * RetBuffer - Pointer to a buffer structure for the 613 * results 614 * 615 * RETURN: Status 616 * 617 * DESCRIPTION: This function is called to get the _PRS value of an object 618 * contained in an object specified by the handle passed in 619 * 620 * If the function fails an appropriate status will be returned 621 * and the contents of the callers buffer is undefined. 622 * 623 ******************************************************************************/ 624 625 ACPI_STATUS 626 AcpiRsGetPrsMethodData ( 627 ACPI_NAMESPACE_NODE *Node, 628 ACPI_BUFFER *RetBuffer) 629 { 630 ACPI_OPERAND_OBJECT *ObjDesc; 631 ACPI_STATUS Status; 632 633 634 ACPI_FUNCTION_TRACE (RsGetPrsMethodData); 635 636 637 /* Parameters guaranteed valid by caller */ 638 639 /* Execute the method, no parameters */ 640 641 Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRS, 642 ACPI_BTYPE_BUFFER, &ObjDesc); 643 if (ACPI_FAILURE (Status)) 644 { 645 return_ACPI_STATUS (Status); 646 } 647 648 /* 649 * Make the call to create a resource linked list from the 650 * byte stream buffer that comes back from the _CRS method 651 * execution. 652 */ 653 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); 654 655 /* On exit, we must delete the object returned by evaluateObject */ 656 657 AcpiUtRemoveReference (ObjDesc); 658 return_ACPI_STATUS (Status); 659 } 660 661 662 /******************************************************************************* 663 * 664 * FUNCTION: AcpiRsGetAeiMethodData 665 * 666 * PARAMETERS: Node - Device node 667 * RetBuffer - Pointer to a buffer structure for the 668 * results 669 * 670 * RETURN: Status 671 * 672 * DESCRIPTION: This function is called to get the _AEI value of an object 673 * contained in an object specified by the handle passed in 674 * 675 * If the function fails an appropriate status will be returned 676 * and the contents of the callers buffer is undefined. 677 * 678 ******************************************************************************/ 679 680 ACPI_STATUS 681 AcpiRsGetAeiMethodData ( 682 ACPI_NAMESPACE_NODE *Node, 683 ACPI_BUFFER *RetBuffer) 684 { 685 ACPI_OPERAND_OBJECT *ObjDesc; 686 ACPI_STATUS Status; 687 688 689 ACPI_FUNCTION_TRACE (RsGetAeiMethodData); 690 691 692 /* Parameters guaranteed valid by caller */ 693 694 /* Execute the method, no parameters */ 695 696 Status = AcpiUtEvaluateObject (Node, METHOD_NAME__AEI, 697 ACPI_BTYPE_BUFFER, &ObjDesc); 698 if (ACPI_FAILURE (Status)) 699 { 700 return_ACPI_STATUS (Status); 701 } 702 703 /* 704 * Make the call to create a resource linked list from the 705 * byte stream buffer that comes back from the _CRS method 706 * execution. 707 */ 708 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); 709 710 /* On exit, we must delete the object returned by evaluateObject */ 711 712 AcpiUtRemoveReference (ObjDesc); 713 return_ACPI_STATUS (Status); 714 } 715 716 717 /******************************************************************************* 718 * 719 * FUNCTION: AcpiRsGetMethodData 720 * 721 * PARAMETERS: Handle - Handle to the containing object 722 * Path - Path to method, relative to Handle 723 * RetBuffer - Pointer to a buffer structure for the 724 * results 725 * 726 * RETURN: Status 727 * 728 * DESCRIPTION: This function is called to get the _CRS or _PRS value of an 729 * object contained in an object specified by the handle passed in 730 * 731 * If the function fails an appropriate status will be returned 732 * and the contents of the callers buffer is undefined. 733 * 734 ******************************************************************************/ 735 736 ACPI_STATUS 737 AcpiRsGetMethodData ( 738 ACPI_HANDLE Handle, 739 char *Path, 740 ACPI_BUFFER *RetBuffer) 741 { 742 ACPI_OPERAND_OBJECT *ObjDesc; 743 ACPI_STATUS Status; 744 745 746 ACPI_FUNCTION_TRACE (RsGetMethodData); 747 748 749 /* Parameters guaranteed valid by caller */ 750 751 /* Execute the method, no parameters */ 752 753 Status = AcpiUtEvaluateObject (ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Handle), 754 Path, ACPI_BTYPE_BUFFER, &ObjDesc); 755 if (ACPI_FAILURE (Status)) 756 { 757 return_ACPI_STATUS (Status); 758 } 759 760 /* 761 * Make the call to create a resource linked list from the 762 * byte stream buffer that comes back from the method 763 * execution. 764 */ 765 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); 766 767 /* On exit, we must delete the object returned by EvaluateObject */ 768 769 AcpiUtRemoveReference (ObjDesc); 770 return_ACPI_STATUS (Status); 771 } 772 773 774 /******************************************************************************* 775 * 776 * FUNCTION: AcpiRsSetSrsMethodData 777 * 778 * PARAMETERS: Node - Device node 779 * InBuffer - Pointer to a buffer structure of the 780 * parameter 781 * 782 * RETURN: Status 783 * 784 * DESCRIPTION: This function is called to set the _SRS of an object contained 785 * in an object specified by the handle passed in 786 * 787 * If the function fails an appropriate status will be returned 788 * and the contents of the callers buffer is undefined. 789 * 790 * Note: Parameters guaranteed valid by caller 791 * 792 ******************************************************************************/ 793 794 ACPI_STATUS 795 AcpiRsSetSrsMethodData ( 796 ACPI_NAMESPACE_NODE *Node, 797 ACPI_BUFFER *InBuffer) 798 { 799 ACPI_EVALUATE_INFO *Info; 800 ACPI_OPERAND_OBJECT *Args[2]; 801 ACPI_STATUS Status; 802 ACPI_BUFFER Buffer; 803 804 805 ACPI_FUNCTION_TRACE (RsSetSrsMethodData); 806 807 808 /* Allocate and initialize the evaluation information block */ 809 810 Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); 811 if (!Info) 812 { 813 return_ACPI_STATUS (AE_NO_MEMORY); 814 } 815 816 Info->PrefixNode = Node; 817 Info->RelativePathname = METHOD_NAME__SRS; 818 Info->Parameters = Args; 819 Info->Flags = ACPI_IGNORE_RETURN_VALUE; 820 821 /* 822 * The InBuffer parameter will point to a linked list of 823 * resource parameters. It needs to be formatted into a 824 * byte stream to be sent in as an input parameter to _SRS 825 * 826 * Convert the linked list into a byte stream 827 */ 828 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 829 Status = AcpiRsCreateAmlResources (InBuffer, &Buffer); 830 if (ACPI_FAILURE (Status)) 831 { 832 goto Cleanup; 833 } 834 835 /* Create and initialize the method parameter object */ 836 837 Args[0] = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); 838 if (!Args[0]) 839 { 840 /* 841 * Must free the buffer allocated above (otherwise it is freed 842 * later) 843 */ 844 ACPI_FREE (Buffer.Pointer); 845 Status = AE_NO_MEMORY; 846 goto Cleanup; 847 } 848 849 Args[0]->Buffer.Length = (UINT32) Buffer.Length; 850 Args[0]->Buffer.Pointer = Buffer.Pointer; 851 Args[0]->Common.Flags = AOPOBJ_DATA_VALID; 852 Args[1] = NULL; 853 854 /* Execute the method, no return value is expected */ 855 856 Status = AcpiNsEvaluate (Info); 857 858 /* Clean up and return the status from AcpiNsEvaluate */ 859 860 AcpiUtRemoveReference (Args[0]); 861 862 Cleanup: 863 ACPI_FREE (Info); 864 return_ACPI_STATUS (Status); 865 } 866