1207536Smav/******************************************************************************* 2207536Smav * 3207536Smav * Module Name: rsutils - Utilities for the resource manager 4207536Smav * 5207536Smav ******************************************************************************/ 6207536Smav 7207536Smav/* 8207536Smav * Copyright (C) 2000 - 2016, Intel Corp. 9207536Smav * All rights reserved. 10207536Smav * 11207536Smav * Redistribution and use in source and binary forms, with or without 12207536Smav * modification, are permitted provided that the following conditions 13207536Smav * are met: 14207536Smav * 1. Redistributions of source code must retain the above copyright 15207536Smav * notice, this list of conditions, and the following disclaimer, 16207536Smav * without modification. 17207536Smav * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18207536Smav * substantially similar to the "NO WARRANTY" disclaimer below 19207536Smav * ("Disclaimer") and any redistribution must be conditioned upon 20207536Smav * including a substantially similar Disclaimer requirement for further 21207536Smav * binary redistribution. 22207536Smav * 3. Neither the names of the above-listed copyright holders nor the names 23207536Smav * of any contributors may be used to endorse or promote products derived 24207536Smav * from this software without specific prior written permission. 25207536Smav * 26207536Smav * Alternatively, this software may be distributed under the terms of the 27207536Smav * GNU General Public License ("GPL") version 2 as published by the Free 28207536Smav * Software Foundation. 29207536Smav * 30207536Smav * NO WARRANTY 31207536Smav * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32207536Smav * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33207536Smav * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34207536Smav * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35207536Smav * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36207536Smav * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37207536Smav * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38207536Smav * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39207536Smav * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40207536Smav * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41207536Smav * POSSIBILITY OF SUCH DAMAGES. 42207536Smav */ 43207536Smav 44207536Smav#include <contrib/dev/acpica/include/acpi.h> 45207536Smav#include <contrib/dev/acpica/include/accommon.h> 46220097Smav#include <contrib/dev/acpica/include/acnamesp.h> 47220097Smav#include <contrib/dev/acpica/include/acresrc.h> 48207536Smav 49207536Smav 50207536Smav#define _COMPONENT ACPI_RESOURCES 51207536Smav ACPI_MODULE_NAME ("rsutils") 52207536Smav 53207536Smav 54207536Smav/******************************************************************************* 55207536Smav * 56207536Smav * FUNCTION: AcpiRsDecodeBitmask 57207536Smav * 58207536Smav * PARAMETERS: Mask - Bitmask to decode 59207536Smav * List - Where the converted list is returned 60207536Smav * 61207536Smav * RETURN: Count of bits set (length of list) 62207536Smav * 63207536Smav * DESCRIPTION: Convert a bit mask into a list of values 64207536Smav * 65207536Smav ******************************************************************************/ 66238873Shrs 67207536SmavUINT8 68207536SmavAcpiRsDecodeBitmask ( 69257240Szbb UINT16 Mask, 70257240Szbb UINT8 *List) 71207536Smav{ 72207536Smav UINT8 i; 73207536Smav UINT8 BitCount; 74207536Smav 75207536Smav 76207536Smav ACPI_FUNCTION_ENTRY (); 77207536Smav 78207536Smav 79207536Smav /* Decode the mask bits */ 80207536Smav 81261410Sian for (i = 0, BitCount = 0; Mask; i++) 82261410Sian { 83261410Sian if (Mask & 0x0001) 84220097Smav { 85220097Smav List[BitCount] = i; 86220097Smav BitCount++; 87207536Smav } 88207536Smav 89207536Smav Mask >>= 1; 90207536Smav } 91207536Smav 92207536Smav return (BitCount); 93207536Smav} 94280393Smav 95207536Smav 96207536Smav/******************************************************************************* 97207536Smav * 98207536Smav * FUNCTION: AcpiRsEncodeBitmask 99207536Smav * 100207536Smav * PARAMETERS: List - List of values to encode 101207536Smav * Count - Length of list 102207536Smav * 103207536Smav * RETURN: Encoded bitmask 104207536Smav * 105207536Smav * DESCRIPTION: Convert a list of values to an encoded bitmask 106207536Smav * 107207536Smav ******************************************************************************/ 108207536Smav 109207536SmavUINT16 110207536SmavAcpiRsEncodeBitmask ( 111207536Smav UINT8 *List, 112207536Smav UINT8 Count) 113207536Smav{ 114207536Smav UINT32 i; 115207536Smav UINT16 Mask; 116207536Smav 117271461Smav 118207536Smav ACPI_FUNCTION_ENTRY (); 119207536Smav 120207536Smav 121207536Smav /* Encode the list into a single bitmask */ 122207536Smav 123207536Smav for (i = 0, Mask = 0; i < Count; i++) 124207536Smav { 125207536Smav Mask |= (0x1 << List[i]); 126207536Smav } 127207536Smav 128207536Smav return (Mask); 129207536Smav} 130207536Smav 131207536Smav 132207536Smav/******************************************************************************* 133207536Smav * 134207536Smav * FUNCTION: AcpiRsMoveData 135207536Smav * 136207536Smav * PARAMETERS: Destination - Pointer to the destination descriptor 137207536Smav * Source - Pointer to the source descriptor 138207536Smav * ItemCount - How many items to move 139207536Smav * MoveType - Byte width 140207536Smav * 141207536Smav * RETURN: None 142207536Smav * 143207536Smav * DESCRIPTION: Move multiple data items from one descriptor to another. Handles 144207536Smav * alignment issues and endian issues if necessary, as configured 145236952Smav * via the ACPI_MOVE_* macros. (This is why a memcpy is not used) 146236952Smav * 147207536Smav ******************************************************************************/ 148208414Smav 149208414Smavvoid 150207536SmavAcpiRsMoveData ( 151207536Smav void *Destination, 152207536Smav void *Source, 153207536Smav UINT16 ItemCount, 154207536Smav UINT8 MoveType) 155207536Smav{ 156207536Smav UINT32 i; 157207536Smav 158207536Smav 159207536Smav ACPI_FUNCTION_ENTRY (); 160207536Smav 161207536Smav 162207536Smav /* One move per item */ 163207536Smav 164207536Smav for (i = 0; i < ItemCount; i++) 165207536Smav { 166207536Smav switch (MoveType) 167207536Smav { 168207536Smav /* 169207536Smav * For the 8-bit case, we can perform the move all at once 170207536Smav * since there are no alignment or endian issues 171207536Smav */ 172207536Smav case ACPI_RSC_MOVE8: 173207536Smav case ACPI_RSC_MOVE_GPIO_RES: 174207536Smav case ACPI_RSC_MOVE_SERIAL_VEN: 175207536Smav case ACPI_RSC_MOVE_SERIAL_RES: 176207536Smav 177207536Smav memcpy (Destination, Source, ItemCount); 178207536Smav return; 179207536Smav 180207536Smav /* 181207536Smav * 16-, 32-, and 64-bit cases must use the move macros that perform 182207536Smav * endian conversion and/or accommodate hardware that cannot perform 183207536Smav * misaligned memory transfers 184207536Smav */ 185207536Smav case ACPI_RSC_MOVE16: 186207536Smav case ACPI_RSC_MOVE_GPIO_PIN: 187227849Shselasky 188227701Shselasky ACPI_MOVE_16_TO_16 ( 189207536Smav &ACPI_CAST_PTR (UINT16, Destination)[i], 190207536Smav &ACPI_CAST_PTR (UINT16, Source)[i]); 191207536Smav break; 192207536Smav 193207536Smav case ACPI_RSC_MOVE32: 194207536Smav 195207536Smav ACPI_MOVE_32_TO_32 ( 196207536Smav &ACPI_CAST_PTR (UINT32, Destination)[i], 197207536Smav &ACPI_CAST_PTR (UINT32, Source)[i]); 198207536Smav break; 199207536Smav 200207536Smav case ACPI_RSC_MOVE64: 201207536Smav 202207536Smav ACPI_MOVE_64_TO_64 ( 203207536Smav &ACPI_CAST_PTR (UINT64, Destination)[i], 204207536Smav &ACPI_CAST_PTR (UINT64, Source)[i]); 205207536Smav break; 206207536Smav 207207536Smav default: 208207536Smav 209207536Smav return; 210207536Smav } 211207536Smav } 212207536Smav} 213207536Smav 214207536Smav 215207536Smav/******************************************************************************* 216207536Smav * 217207536Smav * FUNCTION: AcpiRsSetResourceLength 218207536Smav * 219207536Smav * PARAMETERS: TotalLength - Length of the AML descriptor, including 220207536Smav * the header and length fields. 221207536Smav * Aml - Pointer to the raw AML descriptor 222207536Smav * 223207536Smav * RETURN: None 224207536Smav * 225207536Smav * DESCRIPTION: Set the ResourceLength field of an AML 226207536Smav * resource descriptor, both Large and Small descriptors are 227207536Smav * supported automatically. Note: Descriptor Type field must 228230865Sraj * be valid. 229230865Sraj * 230230865Sraj ******************************************************************************/ 231207536Smav 232207536Smavvoid 233207536SmavAcpiRsSetResourceLength ( 234207536Smav ACPI_RSDESC_SIZE TotalLength, 235207536Smav AML_RESOURCE *Aml) 236207536Smav{ 237207536Smav ACPI_RS_LENGTH ResourceLength; 238207536Smav 239207536Smav 240207536Smav ACPI_FUNCTION_ENTRY (); 241207536Smav 242207536Smav 243207536Smav /* Length is the total descriptor length minus the header length */ 244207536Smav 245207536Smav ResourceLength = (ACPI_RS_LENGTH) 246207536Smav (TotalLength - AcpiUtGetResourceHeaderLength (Aml)); 247207536Smav 248207536Smav /* Length is stored differently for large and small descriptors */ 249207536Smav 250207536Smav if (Aml->SmallHeader.DescriptorType & ACPI_RESOURCE_NAME_LARGE) 251207536Smav { 252207536Smav /* Large descriptor -- bytes 1-2 contain the 16-bit length */ 253207536Smav 254207536Smav ACPI_MOVE_16_TO_16 ( 255207536Smav &Aml->LargeHeader.ResourceLength, &ResourceLength); 256207536Smav } 257207536Smav else 258207536Smav { 259207536Smav /* 260207536Smav * Small descriptor -- bits 2:0 of byte 0 contain the length 261207536Smav * Clear any existing length, preserving descriptor type bits 262207536Smav */ 263207536Smav Aml->SmallHeader.DescriptorType = (UINT8) 264207536Smav ((Aml->SmallHeader.DescriptorType & 265207536Smav ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK) 266207536Smav | ResourceLength); 267207536Smav } 268207536Smav} 269207536Smav 270207536Smav 271207536Smav/******************************************************************************* 272207536Smav * 273207536Smav * FUNCTION: AcpiRsSetResourceHeader 274207536Smav * 275207536Smav * PARAMETERS: DescriptorType - Byte to be inserted as the type 276207536Smav * TotalLength - Length of the AML descriptor, including 277207536Smav * the header and length fields. 278207536Smav * Aml - Pointer to the raw AML descriptor 279207536Smav * 280207536Smav * RETURN: None 281207536Smav * 282207536Smav * DESCRIPTION: Set the DescriptorType and ResourceLength fields of an AML 283207536Smav * resource descriptor, both Large and Small descriptors are 284207536Smav * supported automatically 285207536Smav * 286207536Smav ******************************************************************************/ 287207536Smav 288207536Smavvoid 289207536SmavAcpiRsSetResourceHeader ( 290207536Smav UINT8 DescriptorType, 291207536Smav ACPI_RSDESC_SIZE TotalLength, 292207536Smav AML_RESOURCE *Aml) 293207536Smav{ 294207536Smav ACPI_FUNCTION_ENTRY (); 295207536Smav 296207536Smav 297207536Smav /* Set the Resource Type */ 298207536Smav 299207536Smav Aml->SmallHeader.DescriptorType = DescriptorType; 300207536Smav 301207536Smav /* Set the Resource Length */ 302207536Smav 303207536Smav AcpiRsSetResourceLength (TotalLength, Aml); 304207536Smav} 305230865Sraj 306207536Smav 307207536Smav/******************************************************************************* 308207536Smav * 309207536Smav * FUNCTION: AcpiRsStrcpy 310207536Smav * 311230865Sraj * PARAMETERS: Destination - Pointer to the destination string 312207536Smav * Source - Pointer to the source string 313207536Smav * 314230865Sraj * RETURN: String length, including NULL terminator 315230865Sraj * 316230865Sraj * DESCRIPTION: Local string copy that returns the string length, saving a 317230865Sraj * strcpy followed by a strlen. 318230865Sraj * 319230865Sraj ******************************************************************************/ 320230865Sraj 321207536Smavstatic UINT16 322207536SmavAcpiRsStrcpy ( 323207536Smav char *Destination, 324230865Sraj char *Source) 325207536Smav{ 326207536Smav UINT16 i; 327207536Smav 328207536Smav 329207536Smav ACPI_FUNCTION_ENTRY (); 330207536Smav 331207536Smav 332207536Smav for (i = 0; Source[i]; i++) 333207536Smav { 334207536Smav Destination[i] = Source[i]; 335207536Smav } 336207536Smav 337207536Smav Destination[i] = 0; 338207536Smav 339294883Sjhibbits /* Return string length including the NULL terminator */ 340207536Smav 341207536Smav return ((UINT16) (i + 1)); 342207536Smav} 343207536Smav 344207536Smav 345207536Smav/******************************************************************************* 346207536Smav * 347207536Smav * FUNCTION: AcpiRsGetResourceSource 348207536Smav * 349207536Smav * PARAMETERS: ResourceLength - Length field of the descriptor 350207536Smav * MinimumLength - Minimum length of the descriptor (minus 351207536Smav * any optional fields) 352207536Smav * ResourceSource - Where the ResourceSource is returned 353207536Smav * Aml - Pointer to the raw AML descriptor 354207536Smav * StringPtr - (optional) where to store the actual 355207536Smav * ResourceSource string 356207536Smav * 357207536Smav * RETURN: Length of the string plus NULL terminator, rounded up to native 358207536Smav * word boundary 359207536Smav * 360207536Smav * DESCRIPTION: Copy the optional ResourceSource data from a raw AML descriptor 361207536Smav * to an internal resource descriptor 362207536Smav * 363207536Smav ******************************************************************************/ 364207536Smav 365207536SmavACPI_RS_LENGTH 366207536SmavAcpiRsGetResourceSource ( 367207536Smav ACPI_RS_LENGTH ResourceLength, 368207536Smav ACPI_RS_LENGTH MinimumLength, 369207536Smav ACPI_RESOURCE_SOURCE *ResourceSource, 370207536Smav AML_RESOURCE *Aml, 371207536Smav char *StringPtr) 372207536Smav{ 373207536Smav ACPI_RSDESC_SIZE TotalLength; 374207536Smav UINT8 *AmlResourceSource; 375207536Smav 376207536Smav 377207536Smav ACPI_FUNCTION_ENTRY (); 378207536Smav 379207536Smav 380207536Smav TotalLength = ResourceLength + sizeof (AML_RESOURCE_LARGE_HEADER); 381207536Smav AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength); 382207536Smav 383207536Smav /* 384207536Smav * ResourceSource is present if the length of the descriptor is longer 385207536Smav * than the minimum length. 386207536Smav * 387207536Smav * Note: Some resource descriptors will have an additional null, so 388207536Smav * we add 1 to the minimum length. 389207536Smav */ 390207536Smav if (TotalLength > (ACPI_RSDESC_SIZE) (MinimumLength + 1)) 391207536Smav { 392207536Smav /* Get the ResourceSourceIndex */ 393207536Smav 394207536Smav ResourceSource->Index = AmlResourceSource[0]; 395207536Smav 396207536Smav ResourceSource->StringPtr = StringPtr; 397207536Smav if (!StringPtr) 398207536Smav { 399207536Smav /* 400207536Smav * String destination pointer is not specified; Set the String 401207536Smav * pointer to the end of the current ResourceSource structure. 402207536Smav */ 403207536Smav ResourceSource->StringPtr = ACPI_ADD_PTR ( 404207536Smav char, ResourceSource, sizeof (ACPI_RESOURCE_SOURCE)); 405207536Smav } 406207536Smav 407207536Smav /* 408207536Smav * In order for the Resource length to be a multiple of the native 409207536Smav * word, calculate the length of the string (+1 for NULL terminator) 410207536Smav * and expand to the next word multiple. 411207536Smav * 412207536Smav * Zero the entire area of the buffer. 413207536Smav */ 414207536Smav TotalLength = (UINT32) strlen ( 415207536Smav ACPI_CAST_PTR (char, &AmlResourceSource[1])) + 1; 416207536Smav 417207536Smav TotalLength = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (TotalLength); 418207536Smav 419207536Smav memset (ResourceSource->StringPtr, 0, TotalLength); 420207536Smav 421207536Smav /* Copy the ResourceSource string to the destination */ 422207536Smav 423207536Smav ResourceSource->StringLength = AcpiRsStrcpy ( 424207536Smav ResourceSource->StringPtr, 425207536Smav ACPI_CAST_PTR (char, &AmlResourceSource[1])); 426207536Smav 427207536Smav return ((ACPI_RS_LENGTH) TotalLength); 428207536Smav } 429208410Smav 430208410Smav /* ResourceSource is not present */ 431208410Smav 432208410Smav ResourceSource->Index = 0; 433208410Smav ResourceSource->StringLength = 0; 434208410Smav ResourceSource->StringPtr = NULL; 435208410Smav return (0); 436208410Smav} 437208410Smav 438208410Smav 439249622Smav/******************************************************************************* 440249622Smav * 441249622Smav * FUNCTION: AcpiRsSetResourceSource 442249622Smav * 443249622Smav * PARAMETERS: Aml - Pointer to the raw AML descriptor 444249622Smav * MinimumLength - Minimum length of the descriptor (minus 445249622Smav * any optional fields) 446207536Smav * ResourceSource - Internal ResourceSource 447207536Smav 448207536Smav * 449207536Smav * RETURN: Total length of the AML descriptor 450207536Smav * 451207536Smav * DESCRIPTION: Convert an optional ResourceSource from internal format to a 452207536Smav * raw AML resource descriptor 453207536Smav * 454207536Smav ******************************************************************************/ 455207536Smav 456207536SmavACPI_RSDESC_SIZE 457249622SmavAcpiRsSetResourceSource ( 458249622Smav AML_RESOURCE *Aml, 459207536Smav ACPI_RS_LENGTH MinimumLength, 460207536Smav ACPI_RESOURCE_SOURCE *ResourceSource) 461207536Smav{ 462207536Smav UINT8 *AmlResourceSource; 463220097Smav ACPI_RSDESC_SIZE DescriptorLength; 464207536Smav 465207536Smav 466207536Smav ACPI_FUNCTION_ENTRY (); 467220097Smav 468220097Smav 469220097Smav DescriptorLength = MinimumLength; 470 471 /* Non-zero string length indicates presence of a ResourceSource */ 472 473 if (ResourceSource->StringLength) 474 { 475 /* Point to the end of the AML descriptor */ 476 477 AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength); 478 479 /* Copy the ResourceSourceIndex */ 480 481 AmlResourceSource[0] = (UINT8) ResourceSource->Index; 482 483 /* Copy the ResourceSource string */ 484 485 strcpy (ACPI_CAST_PTR (char, &AmlResourceSource[1]), 486 ResourceSource->StringPtr); 487 488 /* 489 * Add the length of the string (+ 1 for null terminator) to the 490 * final descriptor length 491 */ 492 DescriptorLength += ((ACPI_RSDESC_SIZE) 493 ResourceSource->StringLength + 1); 494 } 495 496 /* Return the new total length of the AML descriptor */ 497 498 return (DescriptorLength); 499} 500 501 502/******************************************************************************* 503 * 504 * FUNCTION: AcpiRsGetPrtMethodData 505 * 506 * PARAMETERS: Node - Device node 507 * RetBuffer - Pointer to a buffer structure for the 508 * results 509 * 510 * RETURN: Status 511 * 512 * DESCRIPTION: This function is called to get the _PRT value of an object 513 * contained in an object specified by the handle passed in 514 * 515 * If the function fails an appropriate status will be returned 516 * and the contents of the callers buffer is undefined. 517 * 518 ******************************************************************************/ 519 520ACPI_STATUS 521AcpiRsGetPrtMethodData ( 522 ACPI_NAMESPACE_NODE *Node, 523 ACPI_BUFFER *RetBuffer) 524{ 525 ACPI_OPERAND_OBJECT *ObjDesc; 526 ACPI_STATUS Status; 527 528 529 ACPI_FUNCTION_TRACE (RsGetPrtMethodData); 530 531 532 /* Parameters guaranteed valid by caller */ 533 534 /* Execute the method, no parameters */ 535 536 Status = AcpiUtEvaluateObject ( 537 Node, METHOD_NAME__PRT, ACPI_BTYPE_PACKAGE, &ObjDesc); 538 if (ACPI_FAILURE (Status)) 539 { 540 return_ACPI_STATUS (Status); 541 } 542 543 /* 544 * Create a resource linked list from the byte stream buffer that comes 545 * back from the _CRS method execution. 546 */ 547 Status = AcpiRsCreatePciRoutingTable (ObjDesc, RetBuffer); 548 549 /* On exit, we must delete the object returned by EvaluateObject */ 550 551 AcpiUtRemoveReference (ObjDesc); 552 return_ACPI_STATUS (Status); 553} 554 555 556/******************************************************************************* 557 * 558 * FUNCTION: AcpiRsGetCrsMethodData 559 * 560 * PARAMETERS: Node - Device node 561 * RetBuffer - Pointer to a buffer structure for the 562 * results 563 * 564 * RETURN: Status 565 * 566 * DESCRIPTION: This function is called to get the _CRS value of an object 567 * contained in an object specified by the handle passed in 568 * 569 * If the function fails an appropriate status will be returned 570 * and the contents of the callers buffer is undefined. 571 * 572 ******************************************************************************/ 573 574ACPI_STATUS 575AcpiRsGetCrsMethodData ( 576 ACPI_NAMESPACE_NODE *Node, 577 ACPI_BUFFER *RetBuffer) 578{ 579 ACPI_OPERAND_OBJECT *ObjDesc; 580 ACPI_STATUS Status; 581 582 583 ACPI_FUNCTION_TRACE (RsGetCrsMethodData); 584 585 586 /* Parameters guaranteed valid by caller */ 587 588 /* Execute the method, no parameters */ 589 590 Status = AcpiUtEvaluateObject ( 591 Node, METHOD_NAME__CRS, ACPI_BTYPE_BUFFER, &ObjDesc); 592 if (ACPI_FAILURE (Status)) 593 { 594 return_ACPI_STATUS (Status); 595 } 596 597 /* 598 * Make the call to create a resource linked list from the 599 * byte stream buffer that comes back from the _CRS method 600 * execution. 601 */ 602 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); 603 604 /* On exit, we must delete the object returned by evaluateObject */ 605 606 AcpiUtRemoveReference (ObjDesc); 607 return_ACPI_STATUS (Status); 608} 609 610 611/******************************************************************************* 612 * 613 * FUNCTION: AcpiRsGetPrsMethodData 614 * 615 * PARAMETERS: Node - Device node 616 * RetBuffer - Pointer to a buffer structure for the 617 * results 618 * 619 * RETURN: Status 620 * 621 * DESCRIPTION: This function is called to get the _PRS value of an object 622 * contained in an object specified by the handle passed in 623 * 624 * If the function fails an appropriate status will be returned 625 * and the contents of the callers buffer is undefined. 626 * 627 ******************************************************************************/ 628 629ACPI_STATUS 630AcpiRsGetPrsMethodData ( 631 ACPI_NAMESPACE_NODE *Node, 632 ACPI_BUFFER *RetBuffer) 633{ 634 ACPI_OPERAND_OBJECT *ObjDesc; 635 ACPI_STATUS Status; 636 637 638 ACPI_FUNCTION_TRACE (RsGetPrsMethodData); 639 640 641 /* Parameters guaranteed valid by caller */ 642 643 /* Execute the method, no parameters */ 644 645 Status = AcpiUtEvaluateObject ( 646 Node, METHOD_NAME__PRS, ACPI_BTYPE_BUFFER, &ObjDesc); 647 if (ACPI_FAILURE (Status)) 648 { 649 return_ACPI_STATUS (Status); 650 } 651 652 /* 653 * Make the call to create a resource linked list from the 654 * byte stream buffer that comes back from the _CRS method 655 * execution. 656 */ 657 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); 658 659 /* On exit, we must delete the object returned by evaluateObject */ 660 661 AcpiUtRemoveReference (ObjDesc); 662 return_ACPI_STATUS (Status); 663} 664 665 666/******************************************************************************* 667 * 668 * FUNCTION: AcpiRsGetAeiMethodData 669 * 670 * PARAMETERS: Node - Device node 671 * RetBuffer - Pointer to a buffer structure for the 672 * results 673 * 674 * RETURN: Status 675 * 676 * DESCRIPTION: This function is called to get the _AEI value of an object 677 * contained in an object specified by the handle passed in 678 * 679 * If the function fails an appropriate status will be returned 680 * and the contents of the callers buffer is undefined. 681 * 682 ******************************************************************************/ 683 684ACPI_STATUS 685AcpiRsGetAeiMethodData ( 686 ACPI_NAMESPACE_NODE *Node, 687 ACPI_BUFFER *RetBuffer) 688{ 689 ACPI_OPERAND_OBJECT *ObjDesc; 690 ACPI_STATUS Status; 691 692 693 ACPI_FUNCTION_TRACE (RsGetAeiMethodData); 694 695 696 /* Parameters guaranteed valid by caller */ 697 698 /* Execute the method, no parameters */ 699 700 Status = AcpiUtEvaluateObject ( 701 Node, METHOD_NAME__AEI, ACPI_BTYPE_BUFFER, &ObjDesc); 702 if (ACPI_FAILURE (Status)) 703 { 704 return_ACPI_STATUS (Status); 705 } 706 707 /* 708 * Make the call to create a resource linked list from the 709 * byte stream buffer that comes back from the _CRS method 710 * execution. 711 */ 712 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); 713 714 /* On exit, we must delete the object returned by evaluateObject */ 715 716 AcpiUtRemoveReference (ObjDesc); 717 return_ACPI_STATUS (Status); 718} 719 720 721/******************************************************************************* 722 * 723 * FUNCTION: AcpiRsGetMethodData 724 * 725 * PARAMETERS: Handle - Handle to the containing object 726 * Path - Path to method, relative to Handle 727 * RetBuffer - Pointer to a buffer structure for the 728 * results 729 * 730 * RETURN: Status 731 * 732 * DESCRIPTION: This function is called to get the _CRS or _PRS value of an 733 * object contained in an object specified by the handle passed in 734 * 735 * If the function fails an appropriate status will be returned 736 * and the contents of the callers buffer is undefined. 737 * 738 ******************************************************************************/ 739 740ACPI_STATUS 741AcpiRsGetMethodData ( 742 ACPI_HANDLE Handle, 743 const char *Path, 744 ACPI_BUFFER *RetBuffer) 745{ 746 ACPI_OPERAND_OBJECT *ObjDesc; 747 ACPI_STATUS Status; 748 749 750 ACPI_FUNCTION_TRACE (RsGetMethodData); 751 752 753 /* Parameters guaranteed valid by caller */ 754 755 /* Execute the method, no parameters */ 756 757 Status = AcpiUtEvaluateObject ( 758 ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Handle), 759 Path, ACPI_BTYPE_BUFFER, &ObjDesc); 760 if (ACPI_FAILURE (Status)) 761 { 762 return_ACPI_STATUS (Status); 763 } 764 765 /* 766 * Make the call to create a resource linked list from the 767 * byte stream buffer that comes back from the method 768 * execution. 769 */ 770 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); 771 772 /* On exit, we must delete the object returned by EvaluateObject */ 773 774 AcpiUtRemoveReference (ObjDesc); 775 return_ACPI_STATUS (Status); 776} 777 778 779/******************************************************************************* 780 * 781 * FUNCTION: AcpiRsSetSrsMethodData 782 * 783 * PARAMETERS: Node - Device node 784 * InBuffer - Pointer to a buffer structure of the 785 * parameter 786 * 787 * RETURN: Status 788 * 789 * DESCRIPTION: This function is called to set the _SRS of an object contained 790 * in an object specified by the handle passed in 791 * 792 * If the function fails an appropriate status will be returned 793 * and the contents of the callers buffer is undefined. 794 * 795 * Note: Parameters guaranteed valid by caller 796 * 797 ******************************************************************************/ 798 799ACPI_STATUS 800AcpiRsSetSrsMethodData ( 801 ACPI_NAMESPACE_NODE *Node, 802 ACPI_BUFFER *InBuffer) 803{ 804 ACPI_EVALUATE_INFO *Info; 805 ACPI_OPERAND_OBJECT *Args[2]; 806 ACPI_STATUS Status; 807 ACPI_BUFFER Buffer; 808 809 810 ACPI_FUNCTION_TRACE (RsSetSrsMethodData); 811 812 813 /* Allocate and initialize the evaluation information block */ 814 815 Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); 816 if (!Info) 817 { 818 return_ACPI_STATUS (AE_NO_MEMORY); 819 } 820 821 Info->PrefixNode = Node; 822 Info->RelativePathname = METHOD_NAME__SRS; 823 Info->Parameters = Args; 824 Info->Flags = ACPI_IGNORE_RETURN_VALUE; 825 826 /* 827 * The InBuffer parameter will point to a linked list of 828 * resource parameters. It needs to be formatted into a 829 * byte stream to be sent in as an input parameter to _SRS 830 * 831 * Convert the linked list into a byte stream 832 */ 833 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 834 Status = AcpiRsCreateAmlResources (InBuffer, &Buffer); 835 if (ACPI_FAILURE (Status)) 836 { 837 goto Cleanup; 838 } 839 840 /* Create and initialize the method parameter object */ 841 842 Args[0] = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); 843 if (!Args[0]) 844 { 845 /* 846 * Must free the buffer allocated above (otherwise it is freed 847 * later) 848 */ 849 ACPI_FREE (Buffer.Pointer); 850 Status = AE_NO_MEMORY; 851 goto Cleanup; 852 } 853 854 Args[0]->Buffer.Length = (UINT32) Buffer.Length; 855 Args[0]->Buffer.Pointer = Buffer.Pointer; 856 Args[0]->Common.Flags = AOPOBJ_DATA_VALID; 857 Args[1] = NULL; 858 859 /* Execute the method, no return value is expected */ 860 861 Status = AcpiNsEvaluate (Info); 862 863 /* Clean up and return the status from AcpiNsEvaluate */ 864 865 AcpiUtRemoveReference (Args[0]); 866 867Cleanup: 868 ACPI_FREE (Info); 869 return_ACPI_STATUS (Status); 870} 871