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