rsutils.c revision 281075
167754Smsmith/******************************************************************************* 267754Smsmith * 367754Smsmith * Module Name: rsutils - Utilities for the resource manager 467754Smsmith * 567754Smsmith ******************************************************************************/ 667754Smsmith 7217365Sjkim/* 8281075Sdim * Copyright (C) 2000 - 2015, Intel Corp. 970243Smsmith * All rights reserved. 1067754Smsmith * 11217365Sjkim * Redistribution and use in source and binary forms, with or without 12217365Sjkim * modification, are permitted provided that the following conditions 13217365Sjkim * are met: 14217365Sjkim * 1. Redistributions of source code must retain the above copyright 15217365Sjkim * notice, this list of conditions, and the following disclaimer, 16217365Sjkim * without modification. 17217365Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18217365Sjkim * substantially similar to the "NO WARRANTY" disclaimer below 19217365Sjkim * ("Disclaimer") and any redistribution must be conditioned upon 20217365Sjkim * including a substantially similar Disclaimer requirement for further 21217365Sjkim * binary redistribution. 22217365Sjkim * 3. Neither the names of the above-listed copyright holders nor the names 23217365Sjkim * of any contributors may be used to endorse or promote products derived 24217365Sjkim * from this software without specific prior written permission. 2567754Smsmith * 26217365Sjkim * Alternatively, this software may be distributed under the terms of the 27217365Sjkim * GNU General Public License ("GPL") version 2 as published by the Free 28217365Sjkim * Software Foundation. 2967754Smsmith * 30217365Sjkim * NO WARRANTY 31217365Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32217365Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33217365Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34217365Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35217365Sjkim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36217365Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37217365Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38217365Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39217365Sjkim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40217365Sjkim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41217365Sjkim * POSSIBILITY OF SUCH DAMAGES. 42217365Sjkim */ 4367754Smsmith 44193341Sjkim#include <contrib/dev/acpica/include/acpi.h> 45193341Sjkim#include <contrib/dev/acpica/include/accommon.h> 46193341Sjkim#include <contrib/dev/acpica/include/acnamesp.h> 47193341Sjkim#include <contrib/dev/acpica/include/acresrc.h> 4867754Smsmith 4967754Smsmith 5077424Smsmith#define _COMPONENT ACPI_RESOURCES 5191116Smsmith ACPI_MODULE_NAME ("rsutils") 5267754Smsmith 5367754Smsmith 5467754Smsmith/******************************************************************************* 5567754Smsmith * 56151937Sjkim * FUNCTION: AcpiRsDecodeBitmask 57151937Sjkim * 58151937Sjkim * PARAMETERS: Mask - Bitmask to decode 59151937Sjkim * List - Where the converted list is returned 60151937Sjkim * 61151937Sjkim * RETURN: Count of bits set (length of list) 62151937Sjkim * 63151937Sjkim * DESCRIPTION: Convert a bit mask into a list of values 64151937Sjkim * 65151937Sjkim ******************************************************************************/ 66151937Sjkim 67151937SjkimUINT8 68151937SjkimAcpiRsDecodeBitmask ( 69151937Sjkim UINT16 Mask, 70151937Sjkim UINT8 *List) 71151937Sjkim{ 72193267Sjkim UINT8 i; 73151937Sjkim UINT8 BitCount; 74151937Sjkim 75151937Sjkim 76167802Sjkim ACPI_FUNCTION_ENTRY (); 77167802Sjkim 78167802Sjkim 79151937Sjkim /* Decode the mask bits */ 80151937Sjkim 81151937Sjkim for (i = 0, BitCount = 0; Mask; i++) 82151937Sjkim { 83151937Sjkim if (Mask & 0x0001) 84151937Sjkim { 85193267Sjkim List[BitCount] = i; 86151937Sjkim BitCount++; 87151937Sjkim } 88151937Sjkim 89151937Sjkim Mask >>= 1; 90151937Sjkim } 91151937Sjkim 92151937Sjkim return (BitCount); 93151937Sjkim} 94151937Sjkim 95151937Sjkim 96151937Sjkim/******************************************************************************* 97151937Sjkim * 98151937Sjkim * FUNCTION: AcpiRsEncodeBitmask 99151937Sjkim * 100151937Sjkim * PARAMETERS: List - List of values to encode 101151937Sjkim * Count - Length of list 102151937Sjkim * 103151937Sjkim * RETURN: Encoded bitmask 104151937Sjkim * 105151937Sjkim * DESCRIPTION: Convert a list of values to an encoded bitmask 106151937Sjkim * 107151937Sjkim ******************************************************************************/ 108151937Sjkim 109151937SjkimUINT16 110151937SjkimAcpiRsEncodeBitmask ( 111151937Sjkim UINT8 *List, 112151937Sjkim UINT8 Count) 113151937Sjkim{ 114193267Sjkim UINT32 i; 115151937Sjkim UINT16 Mask; 116151937Sjkim 117151937Sjkim 118167802Sjkim ACPI_FUNCTION_ENTRY (); 119167802Sjkim 120167802Sjkim 121151937Sjkim /* Encode the list into a single bitmask */ 122151937Sjkim 123151937Sjkim for (i = 0, Mask = 0; i < Count; i++) 124151937Sjkim { 125193267Sjkim Mask |= (0x1 << List[i]); 126151937Sjkim } 127151937Sjkim 128151937Sjkim return (Mask); 129151937Sjkim} 130151937Sjkim 131151937Sjkim 132151937Sjkim/******************************************************************************* 133151937Sjkim * 134151937Sjkim * FUNCTION: AcpiRsMoveData 135151937Sjkim * 136151937Sjkim * PARAMETERS: Destination - Pointer to the destination descriptor 137151937Sjkim * Source - Pointer to the source descriptor 138151937Sjkim * ItemCount - How many items to move 139151937Sjkim * MoveType - Byte width 140151937Sjkim * 141151937Sjkim * RETURN: None 142151937Sjkim * 143151937Sjkim * DESCRIPTION: Move multiple data items from one descriptor to another. Handles 144151937Sjkim * alignment issues and endian issues if necessary, as configured 145151937Sjkim * via the ACPI_MOVE_* macros. (This is why a memcpy is not used) 146151937Sjkim * 147151937Sjkim ******************************************************************************/ 148151937Sjkim 149151937Sjkimvoid 150151937SjkimAcpiRsMoveData ( 151151937Sjkim void *Destination, 152151937Sjkim void *Source, 153151937Sjkim UINT16 ItemCount, 154151937Sjkim UINT8 MoveType) 155151937Sjkim{ 156193267Sjkim UINT32 i; 157151937Sjkim 158151937Sjkim 159167802Sjkim ACPI_FUNCTION_ENTRY (); 160167802Sjkim 161167802Sjkim 162151937Sjkim /* One move per item */ 163151937Sjkim 164151937Sjkim for (i = 0; i < ItemCount; i++) 165151937Sjkim { 166151937Sjkim switch (MoveType) 167151937Sjkim { 168151937Sjkim /* 169151937Sjkim * For the 8-bit case, we can perform the move all at once 170151937Sjkim * since there are no alignment or endian issues 171151937Sjkim */ 172151937Sjkim case ACPI_RSC_MOVE8: 173228110Sjkim case ACPI_RSC_MOVE_GPIO_RES: 174228110Sjkim case ACPI_RSC_MOVE_SERIAL_VEN: 175228110Sjkim case ACPI_RSC_MOVE_SERIAL_RES: 176250838Sjkim 177151937Sjkim ACPI_MEMCPY (Destination, Source, ItemCount); 178151937Sjkim return; 179151937Sjkim 180151937Sjkim /* 181151937Sjkim * 16-, 32-, and 64-bit cases must use the move macros that perform 182238381Sjkim * endian conversion and/or accommodate hardware that cannot perform 183151937Sjkim * misaligned memory transfers 184151937Sjkim */ 185151937Sjkim case ACPI_RSC_MOVE16: 186228110Sjkim case ACPI_RSC_MOVE_GPIO_PIN: 187250838Sjkim 188167802Sjkim ACPI_MOVE_16_TO_16 (&ACPI_CAST_PTR (UINT16, Destination)[i], 189167802Sjkim &ACPI_CAST_PTR (UINT16, Source)[i]); 190151937Sjkim break; 191151937Sjkim 192151937Sjkim case ACPI_RSC_MOVE32: 193252279Sjkim 194167802Sjkim ACPI_MOVE_32_TO_32 (&ACPI_CAST_PTR (UINT32, Destination)[i], 195167802Sjkim &ACPI_CAST_PTR (UINT32, Source)[i]); 196151937Sjkim break; 197151937Sjkim 198151937Sjkim case ACPI_RSC_MOVE64: 199250838Sjkim 200167802Sjkim ACPI_MOVE_64_TO_64 (&ACPI_CAST_PTR (UINT64, Destination)[i], 201167802Sjkim &ACPI_CAST_PTR (UINT64, Source)[i]); 202151937Sjkim break; 203151937Sjkim 204151937Sjkim default: 205250838Sjkim 206151937Sjkim return; 207151937Sjkim } 208151937Sjkim } 209151937Sjkim} 210151937Sjkim 211151937Sjkim 212151937Sjkim/******************************************************************************* 213151937Sjkim * 214151937Sjkim * FUNCTION: AcpiRsSetResourceLength 215151937Sjkim * 216151937Sjkim * PARAMETERS: TotalLength - Length of the AML descriptor, including 217151937Sjkim * the header and length fields. 218151937Sjkim * Aml - Pointer to the raw AML descriptor 219151937Sjkim * 220151937Sjkim * RETURN: None 221151937Sjkim * 222151937Sjkim * DESCRIPTION: Set the ResourceLength field of an AML 223151937Sjkim * resource descriptor, both Large and Small descriptors are 224151937Sjkim * supported automatically. Note: Descriptor Type field must 225151937Sjkim * be valid. 226151937Sjkim * 227151937Sjkim ******************************************************************************/ 228151937Sjkim 229151937Sjkimvoid 230151937SjkimAcpiRsSetResourceLength ( 231151937Sjkim ACPI_RSDESC_SIZE TotalLength, 232151937Sjkim AML_RESOURCE *Aml) 233151937Sjkim{ 234151937Sjkim ACPI_RS_LENGTH ResourceLength; 235151937Sjkim 236151937Sjkim 237151937Sjkim ACPI_FUNCTION_ENTRY (); 238151937Sjkim 239151937Sjkim 240167802Sjkim /* Length is the total descriptor length minus the header length */ 241151937Sjkim 242167802Sjkim ResourceLength = (ACPI_RS_LENGTH) 243167802Sjkim (TotalLength - AcpiUtGetResourceHeaderLength (Aml)); 244167802Sjkim 245167802Sjkim /* Length is stored differently for large and small descriptors */ 246167802Sjkim 247151937Sjkim if (Aml->SmallHeader.DescriptorType & ACPI_RESOURCE_NAME_LARGE) 248151937Sjkim { 249167802Sjkim /* Large descriptor -- bytes 1-2 contain the 16-bit length */ 250151937Sjkim 251151937Sjkim ACPI_MOVE_16_TO_16 (&Aml->LargeHeader.ResourceLength, &ResourceLength); 252151937Sjkim } 253151937Sjkim else 254151937Sjkim { 255167802Sjkim /* Small descriptor -- bits 2:0 of byte 0 contain the length */ 256151937Sjkim 257151937Sjkim Aml->SmallHeader.DescriptorType = (UINT8) 258151937Sjkim 259151937Sjkim /* Clear any existing length, preserving descriptor type bits */ 260151937Sjkim 261151937Sjkim ((Aml->SmallHeader.DescriptorType & ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK) 262151937Sjkim 263151937Sjkim | ResourceLength); 264151937Sjkim } 265151937Sjkim} 266151937Sjkim 267151937Sjkim 268151937Sjkim/******************************************************************************* 269151937Sjkim * 270151937Sjkim * FUNCTION: AcpiRsSetResourceHeader 271151937Sjkim * 272151937Sjkim * PARAMETERS: DescriptorType - Byte to be inserted as the type 273151937Sjkim * TotalLength - Length of the AML descriptor, including 274151937Sjkim * the header and length fields. 275151937Sjkim * Aml - Pointer to the raw AML descriptor 276151937Sjkim * 277151937Sjkim * RETURN: None 278151937Sjkim * 279151937Sjkim * DESCRIPTION: Set the DescriptorType and ResourceLength fields of an AML 280151937Sjkim * resource descriptor, both Large and Small descriptors are 281151937Sjkim * supported automatically 282151937Sjkim * 283151937Sjkim ******************************************************************************/ 284151937Sjkim 285151937Sjkimvoid 286151937SjkimAcpiRsSetResourceHeader ( 287151937Sjkim UINT8 DescriptorType, 288151937Sjkim ACPI_RSDESC_SIZE TotalLength, 289151937Sjkim AML_RESOURCE *Aml) 290151937Sjkim{ 291151937Sjkim ACPI_FUNCTION_ENTRY (); 292151937Sjkim 293151937Sjkim 294167802Sjkim /* Set the Resource Type */ 295151937Sjkim 296151937Sjkim Aml->SmallHeader.DescriptorType = DescriptorType; 297151937Sjkim 298151937Sjkim /* Set the Resource Length */ 299151937Sjkim 300151937Sjkim AcpiRsSetResourceLength (TotalLength, Aml); 301151937Sjkim} 302151937Sjkim 303151937Sjkim 304151937Sjkim/******************************************************************************* 305151937Sjkim * 306151937Sjkim * FUNCTION: AcpiRsStrcpy 307151937Sjkim * 308151937Sjkim * PARAMETERS: Destination - Pointer to the destination string 309151937Sjkim * Source - Pointer to the source string 310151937Sjkim * 311151937Sjkim * RETURN: String length, including NULL terminator 312151937Sjkim * 313151937Sjkim * DESCRIPTION: Local string copy that returns the string length, saving a 314151937Sjkim * strcpy followed by a strlen. 315151937Sjkim * 316151937Sjkim ******************************************************************************/ 317151937Sjkim 318151937Sjkimstatic UINT16 319151937SjkimAcpiRsStrcpy ( 320151937Sjkim char *Destination, 321151937Sjkim char *Source) 322151937Sjkim{ 323151937Sjkim UINT16 i; 324151937Sjkim 325151937Sjkim 326151937Sjkim ACPI_FUNCTION_ENTRY (); 327151937Sjkim 328151937Sjkim 329151937Sjkim for (i = 0; Source[i]; i++) 330151937Sjkim { 331151937Sjkim Destination[i] = Source[i]; 332151937Sjkim } 333151937Sjkim 334151937Sjkim Destination[i] = 0; 335151937Sjkim 336151937Sjkim /* Return string length including the NULL terminator */ 337151937Sjkim 338151937Sjkim return ((UINT16) (i + 1)); 339151937Sjkim} 340151937Sjkim 341151937Sjkim 342151937Sjkim/******************************************************************************* 343151937Sjkim * 344151937Sjkim * FUNCTION: AcpiRsGetResourceSource 345151937Sjkim * 346151937Sjkim * PARAMETERS: ResourceLength - Length field of the descriptor 347151937Sjkim * MinimumLength - Minimum length of the descriptor (minus 348151937Sjkim * any optional fields) 349151937Sjkim * ResourceSource - Where the ResourceSource is returned 350151937Sjkim * Aml - Pointer to the raw AML descriptor 351151937Sjkim * StringPtr - (optional) where to store the actual 352151937Sjkim * ResourceSource string 353151937Sjkim * 354167802Sjkim * RETURN: Length of the string plus NULL terminator, rounded up to native 355167802Sjkim * word boundary 356151937Sjkim * 357151937Sjkim * DESCRIPTION: Copy the optional ResourceSource data from a raw AML descriptor 358151937Sjkim * to an internal resource descriptor 359151937Sjkim * 360151937Sjkim ******************************************************************************/ 361151937Sjkim 362151937SjkimACPI_RS_LENGTH 363151937SjkimAcpiRsGetResourceSource ( 364151937Sjkim ACPI_RS_LENGTH ResourceLength, 365151937Sjkim ACPI_RS_LENGTH MinimumLength, 366151937Sjkim ACPI_RESOURCE_SOURCE *ResourceSource, 367151937Sjkim AML_RESOURCE *Aml, 368151937Sjkim char *StringPtr) 369151937Sjkim{ 370151937Sjkim ACPI_RSDESC_SIZE TotalLength; 371151937Sjkim UINT8 *AmlResourceSource; 372151937Sjkim 373151937Sjkim 374151937Sjkim ACPI_FUNCTION_ENTRY (); 375151937Sjkim 376151937Sjkim 377151937Sjkim TotalLength = ResourceLength + sizeof (AML_RESOURCE_LARGE_HEADER); 378167802Sjkim AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength); 379151937Sjkim 380151937Sjkim /* 381151937Sjkim * ResourceSource is present if the length of the descriptor is longer than 382151937Sjkim * the minimum length. 383151937Sjkim * 384151937Sjkim * Note: Some resource descriptors will have an additional null, so 385151937Sjkim * we add 1 to the minimum length. 386151937Sjkim */ 387167802Sjkim if (TotalLength > (ACPI_RSDESC_SIZE) (MinimumLength + 1)) 388151937Sjkim { 389151937Sjkim /* Get the ResourceSourceIndex */ 390151937Sjkim 391151937Sjkim ResourceSource->Index = AmlResourceSource[0]; 392151937Sjkim 393151937Sjkim ResourceSource->StringPtr = StringPtr; 394151937Sjkim if (!StringPtr) 395151937Sjkim { 396151937Sjkim /* 397151937Sjkim * String destination pointer is not specified; Set the String 398151937Sjkim * pointer to the end of the current ResourceSource structure. 399151937Sjkim */ 400167802Sjkim ResourceSource->StringPtr = ACPI_ADD_PTR (char, ResourceSource, 401167802Sjkim sizeof (ACPI_RESOURCE_SOURCE)); 402151937Sjkim } 403151937Sjkim 404151937Sjkim /* 405167802Sjkim * In order for the Resource length to be a multiple of the native 406167802Sjkim * word, calculate the length of the string (+1 for NULL terminator) 407167802Sjkim * and expand to the next word multiple. 408151937Sjkim * 409151937Sjkim * Zero the entire area of the buffer. 410151937Sjkim */ 411167802Sjkim TotalLength = (UINT32) ACPI_STRLEN ( 412167802Sjkim ACPI_CAST_PTR (char, &AmlResourceSource[1])) + 1; 413167802Sjkim TotalLength = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (TotalLength); 414167802Sjkim 415151937Sjkim ACPI_MEMSET (ResourceSource->StringPtr, 0, TotalLength); 416151937Sjkim 417151937Sjkim /* Copy the ResourceSource string to the destination */ 418151937Sjkim 419151937Sjkim ResourceSource->StringLength = AcpiRsStrcpy (ResourceSource->StringPtr, 420167802Sjkim ACPI_CAST_PTR (char, &AmlResourceSource[1])); 421151937Sjkim 422151937Sjkim return ((ACPI_RS_LENGTH) TotalLength); 423151937Sjkim } 424151937Sjkim 425167802Sjkim /* ResourceSource is not present */ 426167802Sjkim 427167802Sjkim ResourceSource->Index = 0; 428167802Sjkim ResourceSource->StringLength = 0; 429167802Sjkim ResourceSource->StringPtr = NULL; 430167802Sjkim return (0); 431151937Sjkim} 432151937Sjkim 433167802Sjkim 434151937Sjkim/******************************************************************************* 435151937Sjkim * 436151937Sjkim * FUNCTION: AcpiRsSetResourceSource 437151937Sjkim * 438151937Sjkim * PARAMETERS: Aml - Pointer to the raw AML descriptor 439151937Sjkim * MinimumLength - Minimum length of the descriptor (minus 440151937Sjkim * any optional fields) 441151937Sjkim * ResourceSource - Internal ResourceSource 442151937Sjkim 443151937Sjkim * 444151937Sjkim * RETURN: Total length of the AML descriptor 445151937Sjkim * 446151937Sjkim * DESCRIPTION: Convert an optional ResourceSource from internal format to a 447151937Sjkim * raw AML resource descriptor 448151937Sjkim * 449151937Sjkim ******************************************************************************/ 450151937Sjkim 451151937SjkimACPI_RSDESC_SIZE 452151937SjkimAcpiRsSetResourceSource ( 453151937Sjkim AML_RESOURCE *Aml, 454151937Sjkim ACPI_RS_LENGTH MinimumLength, 455151937Sjkim ACPI_RESOURCE_SOURCE *ResourceSource) 456151937Sjkim{ 457151937Sjkim UINT8 *AmlResourceSource; 458151937Sjkim ACPI_RSDESC_SIZE DescriptorLength; 459151937Sjkim 460151937Sjkim 461151937Sjkim ACPI_FUNCTION_ENTRY (); 462151937Sjkim 463151937Sjkim 464151937Sjkim DescriptorLength = MinimumLength; 465151937Sjkim 466151937Sjkim /* Non-zero string length indicates presence of a ResourceSource */ 467151937Sjkim 468151937Sjkim if (ResourceSource->StringLength) 469151937Sjkim { 470151937Sjkim /* Point to the end of the AML descriptor */ 471151937Sjkim 472167802Sjkim AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength); 473151937Sjkim 474151937Sjkim /* Copy the ResourceSourceIndex */ 475151937Sjkim 476151937Sjkim AmlResourceSource[0] = (UINT8) ResourceSource->Index; 477151937Sjkim 478151937Sjkim /* Copy the ResourceSource string */ 479151937Sjkim 480167802Sjkim ACPI_STRCPY (ACPI_CAST_PTR (char, &AmlResourceSource[1]), 481167802Sjkim ResourceSource->StringPtr); 482151937Sjkim 483151937Sjkim /* 484151937Sjkim * Add the length of the string (+ 1 for null terminator) to the 485151937Sjkim * final descriptor length 486151937Sjkim */ 487151937Sjkim DescriptorLength += ((ACPI_RSDESC_SIZE) ResourceSource->StringLength + 1); 488151937Sjkim } 489151937Sjkim 490151937Sjkim /* Return the new total length of the AML descriptor */ 491151937Sjkim 492151937Sjkim return (DescriptorLength); 493151937Sjkim} 494151937Sjkim 495151937Sjkim 496151937Sjkim/******************************************************************************* 497151937Sjkim * 49867754Smsmith * FUNCTION: AcpiRsGetPrtMethodData 49967754Smsmith * 500167802Sjkim * PARAMETERS: Node - Device node 501167802Sjkim * RetBuffer - Pointer to a buffer structure for the 502167802Sjkim * results 50367754Smsmith * 50477424Smsmith * RETURN: Status 50567754Smsmith * 50667754Smsmith * DESCRIPTION: This function is called to get the _PRT value of an object 50767754Smsmith * contained in an object specified by the handle passed in 50867754Smsmith * 50967754Smsmith * If the function fails an appropriate status will be returned 51067754Smsmith * and the contents of the callers buffer is undefined. 51167754Smsmith * 51267754Smsmith ******************************************************************************/ 51367754Smsmith 51467754SmsmithACPI_STATUS 51567754SmsmithAcpiRsGetPrtMethodData ( 516167802Sjkim ACPI_NAMESPACE_NODE *Node, 51767754Smsmith ACPI_BUFFER *RetBuffer) 51867754Smsmith{ 51999679Siwasaki ACPI_OPERAND_OBJECT *ObjDesc; 52067754Smsmith ACPI_STATUS Status; 52167754Smsmith 52267754Smsmith 523167802Sjkim ACPI_FUNCTION_TRACE (RsGetPrtMethodData); 52467754Smsmith 52567754Smsmith 52691116Smsmith /* Parameters guaranteed valid by caller */ 52767754Smsmith 528151937Sjkim /* Execute the method, no parameters */ 529151937Sjkim 530167802Sjkim Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRT, 531151937Sjkim ACPI_BTYPE_PACKAGE, &ObjDesc); 53267754Smsmith if (ACPI_FAILURE (Status)) 53367754Smsmith { 53467754Smsmith return_ACPI_STATUS (Status); 53567754Smsmith } 53667754Smsmith 53767754Smsmith /* 53891116Smsmith * Create a resource linked list from the byte stream buffer that comes 53991116Smsmith * back from the _CRS method execution. 54067754Smsmith */ 54199679Siwasaki Status = AcpiRsCreatePciRoutingTable (ObjDesc, RetBuffer); 54267754Smsmith 54391116Smsmith /* On exit, we must delete the object returned by EvaluateObject */ 54467754Smsmith 54599679Siwasaki AcpiUtRemoveReference (ObjDesc); 54667754Smsmith return_ACPI_STATUS (Status); 54767754Smsmith} 54867754Smsmith 54967754Smsmith 55067754Smsmith/******************************************************************************* 55167754Smsmith * 55267754Smsmith * FUNCTION: AcpiRsGetCrsMethodData 55367754Smsmith * 554167802Sjkim * PARAMETERS: Node - Device node 555167802Sjkim * RetBuffer - Pointer to a buffer structure for the 556167802Sjkim * results 55767754Smsmith * 55877424Smsmith * RETURN: Status 55967754Smsmith * 56067754Smsmith * DESCRIPTION: This function is called to get the _CRS value of an object 56167754Smsmith * contained in an object specified by the handle passed in 56267754Smsmith * 56367754Smsmith * If the function fails an appropriate status will be returned 56467754Smsmith * and the contents of the callers buffer is undefined. 56567754Smsmith * 56667754Smsmith ******************************************************************************/ 56767754Smsmith 56867754SmsmithACPI_STATUS 56967754SmsmithAcpiRsGetCrsMethodData ( 570167802Sjkim ACPI_NAMESPACE_NODE *Node, 57167754Smsmith ACPI_BUFFER *RetBuffer) 57267754Smsmith{ 57399679Siwasaki ACPI_OPERAND_OBJECT *ObjDesc; 57467754Smsmith ACPI_STATUS Status; 57567754Smsmith 57667754Smsmith 577167802Sjkim ACPI_FUNCTION_TRACE (RsGetCrsMethodData); 57867754Smsmith 57967754Smsmith 58091116Smsmith /* Parameters guaranteed valid by caller */ 58167754Smsmith 582151937Sjkim /* Execute the method, no parameters */ 583151937Sjkim 584167802Sjkim Status = AcpiUtEvaluateObject (Node, METHOD_NAME__CRS, 585151937Sjkim ACPI_BTYPE_BUFFER, &ObjDesc); 58667754Smsmith if (ACPI_FAILURE (Status)) 58767754Smsmith { 58867754Smsmith return_ACPI_STATUS (Status); 58967754Smsmith } 59067754Smsmith 59167754Smsmith /* 59267754Smsmith * Make the call to create a resource linked list from the 59391116Smsmith * byte stream buffer that comes back from the _CRS method 59491116Smsmith * execution. 59567754Smsmith */ 59699679Siwasaki Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); 59767754Smsmith 59867754Smsmith /* On exit, we must delete the object returned by evaluateObject */ 59967754Smsmith 60099679Siwasaki AcpiUtRemoveReference (ObjDesc); 60167754Smsmith return_ACPI_STATUS (Status); 60267754Smsmith} 60367754Smsmith 60467754Smsmith 60567754Smsmith/******************************************************************************* 60667754Smsmith * 60767754Smsmith * FUNCTION: AcpiRsGetPrsMethodData 60867754Smsmith * 609167802Sjkim * PARAMETERS: Node - Device node 610167802Sjkim * RetBuffer - Pointer to a buffer structure for the 611167802Sjkim * results 61267754Smsmith * 61377424Smsmith * RETURN: Status 61467754Smsmith * 61567754Smsmith * DESCRIPTION: This function is called to get the _PRS value of an object 61667754Smsmith * contained in an object specified by the handle passed in 61767754Smsmith * 61867754Smsmith * If the function fails an appropriate status will be returned 61967754Smsmith * and the contents of the callers buffer is undefined. 62067754Smsmith * 62167754Smsmith ******************************************************************************/ 62267754Smsmith 62367754SmsmithACPI_STATUS 62467754SmsmithAcpiRsGetPrsMethodData ( 625167802Sjkim ACPI_NAMESPACE_NODE *Node, 62667754Smsmith ACPI_BUFFER *RetBuffer) 62767754Smsmith{ 62899679Siwasaki ACPI_OPERAND_OBJECT *ObjDesc; 62967754Smsmith ACPI_STATUS Status; 63067754Smsmith 63167754Smsmith 632167802Sjkim ACPI_FUNCTION_TRACE (RsGetPrsMethodData); 63367754Smsmith 63467754Smsmith 63591116Smsmith /* Parameters guaranteed valid by caller */ 63667754Smsmith 637151937Sjkim /* Execute the method, no parameters */ 638151937Sjkim 639167802Sjkim Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRS, 640151937Sjkim ACPI_BTYPE_BUFFER, &ObjDesc); 64167754Smsmith if (ACPI_FAILURE (Status)) 64267754Smsmith { 64367754Smsmith return_ACPI_STATUS (Status); 64467754Smsmith } 64567754Smsmith 646114237Snjl /* 647114237Snjl * Make the call to create a resource linked list from the 648114237Snjl * byte stream buffer that comes back from the _CRS method 649114237Snjl * execution. 650114237Snjl */ 651114237Snjl Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); 65267754Smsmith 653114237Snjl /* On exit, we must delete the object returned by evaluateObject */ 65467754Smsmith 655114237Snjl AcpiUtRemoveReference (ObjDesc); 656114237Snjl return_ACPI_STATUS (Status); 657114237Snjl} 658114237Snjl 659114237Snjl 660114237Snjl/******************************************************************************* 661114237Snjl * 662228110Sjkim * FUNCTION: AcpiRsGetAeiMethodData 663228110Sjkim * 664228110Sjkim * PARAMETERS: Node - Device node 665228110Sjkim * RetBuffer - Pointer to a buffer structure for the 666228110Sjkim * results 667228110Sjkim * 668228110Sjkim * RETURN: Status 669228110Sjkim * 670228110Sjkim * DESCRIPTION: This function is called to get the _AEI value of an object 671228110Sjkim * contained in an object specified by the handle passed in 672228110Sjkim * 673228110Sjkim * If the function fails an appropriate status will be returned 674228110Sjkim * and the contents of the callers buffer is undefined. 675228110Sjkim * 676228110Sjkim ******************************************************************************/ 677228110Sjkim 678228110SjkimACPI_STATUS 679228110SjkimAcpiRsGetAeiMethodData ( 680228110Sjkim ACPI_NAMESPACE_NODE *Node, 681228110Sjkim ACPI_BUFFER *RetBuffer) 682228110Sjkim{ 683228110Sjkim ACPI_OPERAND_OBJECT *ObjDesc; 684228110Sjkim ACPI_STATUS Status; 685228110Sjkim 686228110Sjkim 687228110Sjkim ACPI_FUNCTION_TRACE (RsGetAeiMethodData); 688228110Sjkim 689228110Sjkim 690228110Sjkim /* Parameters guaranteed valid by caller */ 691228110Sjkim 692228110Sjkim /* Execute the method, no parameters */ 693228110Sjkim 694228110Sjkim Status = AcpiUtEvaluateObject (Node, METHOD_NAME__AEI, 695228110Sjkim ACPI_BTYPE_BUFFER, &ObjDesc); 696228110Sjkim if (ACPI_FAILURE (Status)) 697228110Sjkim { 698228110Sjkim return_ACPI_STATUS (Status); 699228110Sjkim } 700228110Sjkim 701228110Sjkim /* 702228110Sjkim * Make the call to create a resource linked list from the 703228110Sjkim * byte stream buffer that comes back from the _CRS method 704228110Sjkim * execution. 705228110Sjkim */ 706228110Sjkim Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); 707228110Sjkim 708228110Sjkim /* On exit, we must delete the object returned by evaluateObject */ 709228110Sjkim 710228110Sjkim AcpiUtRemoveReference (ObjDesc); 711228110Sjkim return_ACPI_STATUS (Status); 712228110Sjkim} 713228110Sjkim 714228110Sjkim 715228110Sjkim/******************************************************************************* 716228110Sjkim * 717114237Snjl * FUNCTION: AcpiRsGetMethodData 718114237Snjl * 719167802Sjkim * PARAMETERS: Handle - Handle to the containing object 720151937Sjkim * Path - Path to method, relative to Handle 721167802Sjkim * RetBuffer - Pointer to a buffer structure for the 722167802Sjkim * results 723114237Snjl * 724114237Snjl * RETURN: Status 725114237Snjl * 726114237Snjl * DESCRIPTION: This function is called to get the _CRS or _PRS value of an 727114237Snjl * object contained in an object specified by the handle passed in 728114237Snjl * 729114237Snjl * If the function fails an appropriate status will be returned 730114237Snjl * and the contents of the callers buffer is undefined. 731114237Snjl * 732114237Snjl ******************************************************************************/ 733114237Snjl 734114237SnjlACPI_STATUS 735114237SnjlAcpiRsGetMethodData ( 736114237Snjl ACPI_HANDLE Handle, 737114237Snjl char *Path, 738114237Snjl ACPI_BUFFER *RetBuffer) 739114237Snjl{ 740114237Snjl ACPI_OPERAND_OBJECT *ObjDesc; 741114237Snjl ACPI_STATUS Status; 742114237Snjl 743114237Snjl 744167802Sjkim ACPI_FUNCTION_TRACE (RsGetMethodData); 745114237Snjl 746114237Snjl 747114237Snjl /* Parameters guaranteed valid by caller */ 748114237Snjl 749151937Sjkim /* Execute the method, no parameters */ 750151937Sjkim 751245582Sjkim Status = AcpiUtEvaluateObject (ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Handle), 752245582Sjkim Path, ACPI_BTYPE_BUFFER, &ObjDesc); 753167802Sjkim if (ACPI_FAILURE (Status)) 754167802Sjkim { 755114237Snjl return_ACPI_STATUS (Status); 75667754Smsmith } 75767754Smsmith 75867754Smsmith /* 75967754Smsmith * Make the call to create a resource linked list from the 760114237Snjl * byte stream buffer that comes back from the method 76191116Smsmith * execution. 76267754Smsmith */ 76399679Siwasaki Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); 76467754Smsmith 765114237Snjl /* On exit, we must delete the object returned by EvaluateObject */ 76667754Smsmith 76799679Siwasaki AcpiUtRemoveReference (ObjDesc); 76867754Smsmith return_ACPI_STATUS (Status); 76967754Smsmith} 77067754Smsmith 771167802Sjkim 77267754Smsmith/******************************************************************************* 77367754Smsmith * 77467754Smsmith * FUNCTION: AcpiRsSetSrsMethodData 77567754Smsmith * 776167802Sjkim * PARAMETERS: Node - Device node 777167802Sjkim * InBuffer - Pointer to a buffer structure of the 778167802Sjkim * parameter 77967754Smsmith * 78077424Smsmith * RETURN: Status 78167754Smsmith * 78267754Smsmith * DESCRIPTION: This function is called to set the _SRS of an object contained 78367754Smsmith * in an object specified by the handle passed in 78467754Smsmith * 78567754Smsmith * If the function fails an appropriate status will be returned 78667754Smsmith * and the contents of the callers buffer is undefined. 78767754Smsmith * 788167802Sjkim * Note: Parameters guaranteed valid by caller 789167802Sjkim * 79067754Smsmith ******************************************************************************/ 79167754Smsmith 79267754SmsmithACPI_STATUS 79367754SmsmithAcpiRsSetSrsMethodData ( 794167802Sjkim ACPI_NAMESPACE_NODE *Node, 79567754Smsmith ACPI_BUFFER *InBuffer) 79667754Smsmith{ 797167802Sjkim ACPI_EVALUATE_INFO *Info; 798167802Sjkim ACPI_OPERAND_OBJECT *Args[2]; 79967754Smsmith ACPI_STATUS Status; 80091116Smsmith ACPI_BUFFER Buffer; 80167754Smsmith 80267754Smsmith 803167802Sjkim ACPI_FUNCTION_TRACE (RsSetSrsMethodData); 80467754Smsmith 80567754Smsmith 806167802Sjkim /* Allocate and initialize the evaluation information block */ 80767754Smsmith 808167802Sjkim Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); 809167802Sjkim if (!Info) 810167802Sjkim { 811167802Sjkim return_ACPI_STATUS (AE_NO_MEMORY); 812167802Sjkim } 813167802Sjkim 814167802Sjkim Info->PrefixNode = Node; 815249663Sjkim Info->RelativePathname = METHOD_NAME__SRS; 816167802Sjkim Info->Parameters = Args; 817167802Sjkim Info->Flags = ACPI_IGNORE_RETURN_VALUE; 818167802Sjkim 81967754Smsmith /* 82067754Smsmith * The InBuffer parameter will point to a linked list of 821167802Sjkim * resource parameters. It needs to be formatted into a 82291116Smsmith * byte stream to be sent in as an input parameter to _SRS 82391116Smsmith * 82491116Smsmith * Convert the linked list into a byte stream 82567754Smsmith */ 82691116Smsmith Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 827281075Sdim Status = AcpiRsCreateAmlResources (InBuffer, &Buffer); 82891116Smsmith if (ACPI_FAILURE (Status)) 82967754Smsmith { 830167802Sjkim goto Cleanup; 83167754Smsmith } 83267754Smsmith 833167802Sjkim /* Create and initialize the method parameter object */ 834151937Sjkim 835167802Sjkim Args[0] = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); 836167802Sjkim if (!Args[0]) 83784491Smsmith { 838167802Sjkim /* 839167802Sjkim * Must free the buffer allocated above (otherwise it is freed 840167802Sjkim * later) 841167802Sjkim */ 842167802Sjkim ACPI_FREE (Buffer.Pointer); 843167802Sjkim Status = AE_NO_MEMORY; 844167802Sjkim goto Cleanup; 84584491Smsmith } 84667754Smsmith 847167802Sjkim Args[0]->Buffer.Length = (UINT32) Buffer.Length; 848167802Sjkim Args[0]->Buffer.Pointer = Buffer.Pointer; 849167802Sjkim Args[0]->Common.Flags = AOPOBJ_DATA_VALID; 850167802Sjkim Args[1] = NULL; 851151937Sjkim 852167802Sjkim /* Execute the method, no return value is expected */ 85367754Smsmith 854167802Sjkim Status = AcpiNsEvaluate (Info); 855129684Snjl 856167802Sjkim /* Clean up and return the status from AcpiNsEvaluate */ 85767754Smsmith 858167802Sjkim AcpiUtRemoveReference (Args[0]); 859151937Sjkim 860167802SjkimCleanup: 861167802Sjkim ACPI_FREE (Info); 86267754Smsmith return_ACPI_STATUS (Status); 86367754Smsmith} 864