167754Smsmith/******************************************************************************* 267754Smsmith * 367754Smsmith * Module Name: rsutils - Utilities for the resource manager 467754Smsmith * 567754Smsmith ******************************************************************************/ 667754Smsmith 7217365Sjkim/* 8306536Sjkim * Copyright (C) 2000 - 2016, 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 177306536Sjkim 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 188306536Sjkim ACPI_MOVE_16_TO_16 ( 189306536Sjkim &ACPI_CAST_PTR (UINT16, Destination)[i], 190306536Sjkim &ACPI_CAST_PTR (UINT16, Source)[i]); 191151937Sjkim break; 192151937Sjkim 193151937Sjkim case ACPI_RSC_MOVE32: 194252279Sjkim 195306536Sjkim ACPI_MOVE_32_TO_32 ( 196306536Sjkim &ACPI_CAST_PTR (UINT32, Destination)[i], 197306536Sjkim &ACPI_CAST_PTR (UINT32, Source)[i]); 198151937Sjkim break; 199151937Sjkim 200151937Sjkim case ACPI_RSC_MOVE64: 201250838Sjkim 202306536Sjkim ACPI_MOVE_64_TO_64 ( 203306536Sjkim &ACPI_CAST_PTR (UINT64, Destination)[i], 204306536Sjkim &ACPI_CAST_PTR (UINT64, Source)[i]); 205151937Sjkim break; 206151937Sjkim 207151937Sjkim default: 208250838Sjkim 209151937Sjkim return; 210151937Sjkim } 211151937Sjkim } 212151937Sjkim} 213151937Sjkim 214151937Sjkim 215151937Sjkim/******************************************************************************* 216151937Sjkim * 217151937Sjkim * FUNCTION: AcpiRsSetResourceLength 218151937Sjkim * 219151937Sjkim * PARAMETERS: TotalLength - Length of the AML descriptor, including 220151937Sjkim * the header and length fields. 221151937Sjkim * Aml - Pointer to the raw AML descriptor 222151937Sjkim * 223151937Sjkim * RETURN: None 224151937Sjkim * 225151937Sjkim * DESCRIPTION: Set the ResourceLength field of an AML 226151937Sjkim * resource descriptor, both Large and Small descriptors are 227151937Sjkim * supported automatically. Note: Descriptor Type field must 228151937Sjkim * be valid. 229151937Sjkim * 230151937Sjkim ******************************************************************************/ 231151937Sjkim 232151937Sjkimvoid 233151937SjkimAcpiRsSetResourceLength ( 234151937Sjkim ACPI_RSDESC_SIZE TotalLength, 235151937Sjkim AML_RESOURCE *Aml) 236151937Sjkim{ 237151937Sjkim ACPI_RS_LENGTH ResourceLength; 238151937Sjkim 239151937Sjkim 240151937Sjkim ACPI_FUNCTION_ENTRY (); 241151937Sjkim 242151937Sjkim 243167802Sjkim /* Length is the total descriptor length minus the header length */ 244151937Sjkim 245167802Sjkim ResourceLength = (ACPI_RS_LENGTH) 246167802Sjkim (TotalLength - AcpiUtGetResourceHeaderLength (Aml)); 247167802Sjkim 248167802Sjkim /* Length is stored differently for large and small descriptors */ 249167802Sjkim 250151937Sjkim if (Aml->SmallHeader.DescriptorType & ACPI_RESOURCE_NAME_LARGE) 251151937Sjkim { 252167802Sjkim /* Large descriptor -- bytes 1-2 contain the 16-bit length */ 253151937Sjkim 254306536Sjkim ACPI_MOVE_16_TO_16 ( 255306536Sjkim &Aml->LargeHeader.ResourceLength, &ResourceLength); 256151937Sjkim } 257151937Sjkim else 258151937Sjkim { 259306536Sjkim /* 260306536Sjkim * Small descriptor -- bits 2:0 of byte 0 contain the length 261306536Sjkim * Clear any existing length, preserving descriptor type bits 262306536Sjkim */ 263151937Sjkim Aml->SmallHeader.DescriptorType = (UINT8) 264306536Sjkim ((Aml->SmallHeader.DescriptorType & 265306536Sjkim ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK) 266151937Sjkim | ResourceLength); 267151937Sjkim } 268151937Sjkim} 269151937Sjkim 270151937Sjkim 271151937Sjkim/******************************************************************************* 272151937Sjkim * 273151937Sjkim * FUNCTION: AcpiRsSetResourceHeader 274151937Sjkim * 275151937Sjkim * PARAMETERS: DescriptorType - Byte to be inserted as the type 276151937Sjkim * TotalLength - Length of the AML descriptor, including 277151937Sjkim * the header and length fields. 278151937Sjkim * Aml - Pointer to the raw AML descriptor 279151937Sjkim * 280151937Sjkim * RETURN: None 281151937Sjkim * 282151937Sjkim * DESCRIPTION: Set the DescriptorType and ResourceLength fields of an AML 283151937Sjkim * resource descriptor, both Large and Small descriptors are 284151937Sjkim * supported automatically 285151937Sjkim * 286151937Sjkim ******************************************************************************/ 287151937Sjkim 288151937Sjkimvoid 289151937SjkimAcpiRsSetResourceHeader ( 290151937Sjkim UINT8 DescriptorType, 291151937Sjkim ACPI_RSDESC_SIZE TotalLength, 292151937Sjkim AML_RESOURCE *Aml) 293151937Sjkim{ 294151937Sjkim ACPI_FUNCTION_ENTRY (); 295151937Sjkim 296151937Sjkim 297167802Sjkim /* Set the Resource Type */ 298151937Sjkim 299151937Sjkim Aml->SmallHeader.DescriptorType = DescriptorType; 300151937Sjkim 301151937Sjkim /* Set the Resource Length */ 302151937Sjkim 303151937Sjkim AcpiRsSetResourceLength (TotalLength, Aml); 304151937Sjkim} 305151937Sjkim 306151937Sjkim 307151937Sjkim/******************************************************************************* 308151937Sjkim * 309151937Sjkim * FUNCTION: AcpiRsStrcpy 310151937Sjkim * 311151937Sjkim * PARAMETERS: Destination - Pointer to the destination string 312151937Sjkim * Source - Pointer to the source string 313151937Sjkim * 314151937Sjkim * RETURN: String length, including NULL terminator 315151937Sjkim * 316151937Sjkim * DESCRIPTION: Local string copy that returns the string length, saving a 317151937Sjkim * strcpy followed by a strlen. 318151937Sjkim * 319151937Sjkim ******************************************************************************/ 320151937Sjkim 321151937Sjkimstatic UINT16 322151937SjkimAcpiRsStrcpy ( 323151937Sjkim char *Destination, 324151937Sjkim char *Source) 325151937Sjkim{ 326151937Sjkim UINT16 i; 327151937Sjkim 328151937Sjkim 329151937Sjkim ACPI_FUNCTION_ENTRY (); 330151937Sjkim 331151937Sjkim 332151937Sjkim for (i = 0; Source[i]; i++) 333151937Sjkim { 334151937Sjkim Destination[i] = Source[i]; 335151937Sjkim } 336151937Sjkim 337151937Sjkim Destination[i] = 0; 338151937Sjkim 339151937Sjkim /* Return string length including the NULL terminator */ 340151937Sjkim 341151937Sjkim return ((UINT16) (i + 1)); 342151937Sjkim} 343151937Sjkim 344151937Sjkim 345151937Sjkim/******************************************************************************* 346151937Sjkim * 347151937Sjkim * FUNCTION: AcpiRsGetResourceSource 348151937Sjkim * 349151937Sjkim * PARAMETERS: ResourceLength - Length field of the descriptor 350151937Sjkim * MinimumLength - Minimum length of the descriptor (minus 351151937Sjkim * any optional fields) 352151937Sjkim * ResourceSource - Where the ResourceSource is returned 353151937Sjkim * Aml - Pointer to the raw AML descriptor 354151937Sjkim * StringPtr - (optional) where to store the actual 355151937Sjkim * ResourceSource string 356151937Sjkim * 357167802Sjkim * RETURN: Length of the string plus NULL terminator, rounded up to native 358167802Sjkim * word boundary 359151937Sjkim * 360151937Sjkim * DESCRIPTION: Copy the optional ResourceSource data from a raw AML descriptor 361151937Sjkim * to an internal resource descriptor 362151937Sjkim * 363151937Sjkim ******************************************************************************/ 364151937Sjkim 365151937SjkimACPI_RS_LENGTH 366151937SjkimAcpiRsGetResourceSource ( 367151937Sjkim ACPI_RS_LENGTH ResourceLength, 368151937Sjkim ACPI_RS_LENGTH MinimumLength, 369151937Sjkim ACPI_RESOURCE_SOURCE *ResourceSource, 370151937Sjkim AML_RESOURCE *Aml, 371151937Sjkim char *StringPtr) 372151937Sjkim{ 373151937Sjkim ACPI_RSDESC_SIZE TotalLength; 374151937Sjkim UINT8 *AmlResourceSource; 375151937Sjkim 376151937Sjkim 377151937Sjkim ACPI_FUNCTION_ENTRY (); 378151937Sjkim 379151937Sjkim 380151937Sjkim TotalLength = ResourceLength + sizeof (AML_RESOURCE_LARGE_HEADER); 381167802Sjkim AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength); 382151937Sjkim 383151937Sjkim /* 384306536Sjkim * ResourceSource is present if the length of the descriptor is longer 385306536Sjkim * than the minimum length. 386151937Sjkim * 387151937Sjkim * Note: Some resource descriptors will have an additional null, so 388151937Sjkim * we add 1 to the minimum length. 389151937Sjkim */ 390167802Sjkim if (TotalLength > (ACPI_RSDESC_SIZE) (MinimumLength + 1)) 391151937Sjkim { 392151937Sjkim /* Get the ResourceSourceIndex */ 393151937Sjkim 394151937Sjkim ResourceSource->Index = AmlResourceSource[0]; 395151937Sjkim 396151937Sjkim ResourceSource->StringPtr = StringPtr; 397151937Sjkim if (!StringPtr) 398151937Sjkim { 399151937Sjkim /* 400151937Sjkim * String destination pointer is not specified; Set the String 401151937Sjkim * pointer to the end of the current ResourceSource structure. 402151937Sjkim */ 403306536Sjkim ResourceSource->StringPtr = ACPI_ADD_PTR ( 404306536Sjkim char, ResourceSource, sizeof (ACPI_RESOURCE_SOURCE)); 405151937Sjkim } 406151937Sjkim 407151937Sjkim /* 408167802Sjkim * In order for the Resource length to be a multiple of the native 409167802Sjkim * word, calculate the length of the string (+1 for NULL terminator) 410167802Sjkim * and expand to the next word multiple. 411151937Sjkim * 412151937Sjkim * Zero the entire area of the buffer. 413151937Sjkim */ 414306536Sjkim TotalLength = (UINT32) strlen ( 415167802Sjkim ACPI_CAST_PTR (char, &AmlResourceSource[1])) + 1; 416306536Sjkim 417167802Sjkim TotalLength = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (TotalLength); 418167802Sjkim 419306536Sjkim memset (ResourceSource->StringPtr, 0, TotalLength); 420151937Sjkim 421151937Sjkim /* Copy the ResourceSource string to the destination */ 422151937Sjkim 423306536Sjkim ResourceSource->StringLength = AcpiRsStrcpy ( 424306536Sjkim ResourceSource->StringPtr, 425167802Sjkim ACPI_CAST_PTR (char, &AmlResourceSource[1])); 426151937Sjkim 427151937Sjkim return ((ACPI_RS_LENGTH) TotalLength); 428151937Sjkim } 429151937Sjkim 430167802Sjkim /* ResourceSource is not present */ 431167802Sjkim 432167802Sjkim ResourceSource->Index = 0; 433167802Sjkim ResourceSource->StringLength = 0; 434167802Sjkim ResourceSource->StringPtr = NULL; 435167802Sjkim return (0); 436151937Sjkim} 437151937Sjkim 438167802Sjkim 439151937Sjkim/******************************************************************************* 440151937Sjkim * 441151937Sjkim * FUNCTION: AcpiRsSetResourceSource 442151937Sjkim * 443151937Sjkim * PARAMETERS: Aml - Pointer to the raw AML descriptor 444151937Sjkim * MinimumLength - Minimum length of the descriptor (minus 445151937Sjkim * any optional fields) 446151937Sjkim * ResourceSource - Internal ResourceSource 447151937Sjkim 448151937Sjkim * 449151937Sjkim * RETURN: Total length of the AML descriptor 450151937Sjkim * 451151937Sjkim * DESCRIPTION: Convert an optional ResourceSource from internal format to a 452151937Sjkim * raw AML resource descriptor 453151937Sjkim * 454151937Sjkim ******************************************************************************/ 455151937Sjkim 456151937SjkimACPI_RSDESC_SIZE 457151937SjkimAcpiRsSetResourceSource ( 458151937Sjkim AML_RESOURCE *Aml, 459151937Sjkim ACPI_RS_LENGTH MinimumLength, 460151937Sjkim ACPI_RESOURCE_SOURCE *ResourceSource) 461151937Sjkim{ 462151937Sjkim UINT8 *AmlResourceSource; 463151937Sjkim ACPI_RSDESC_SIZE DescriptorLength; 464151937Sjkim 465151937Sjkim 466151937Sjkim ACPI_FUNCTION_ENTRY (); 467151937Sjkim 468151937Sjkim 469151937Sjkim DescriptorLength = MinimumLength; 470151937Sjkim 471151937Sjkim /* Non-zero string length indicates presence of a ResourceSource */ 472151937Sjkim 473151937Sjkim if (ResourceSource->StringLength) 474151937Sjkim { 475151937Sjkim /* Point to the end of the AML descriptor */ 476151937Sjkim 477167802Sjkim AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength); 478151937Sjkim 479151937Sjkim /* Copy the ResourceSourceIndex */ 480151937Sjkim 481151937Sjkim AmlResourceSource[0] = (UINT8) ResourceSource->Index; 482151937Sjkim 483151937Sjkim /* Copy the ResourceSource string */ 484151937Sjkim 485306536Sjkim strcpy (ACPI_CAST_PTR (char, &AmlResourceSource[1]), 486167802Sjkim ResourceSource->StringPtr); 487151937Sjkim 488151937Sjkim /* 489151937Sjkim * Add the length of the string (+ 1 for null terminator) to the 490151937Sjkim * final descriptor length 491151937Sjkim */ 492306536Sjkim DescriptorLength += ((ACPI_RSDESC_SIZE) 493306536Sjkim ResourceSource->StringLength + 1); 494151937Sjkim } 495151937Sjkim 496151937Sjkim /* Return the new total length of the AML descriptor */ 497151937Sjkim 498151937Sjkim return (DescriptorLength); 499151937Sjkim} 500151937Sjkim 501151937Sjkim 502151937Sjkim/******************************************************************************* 503151937Sjkim * 50467754Smsmith * FUNCTION: AcpiRsGetPrtMethodData 50567754Smsmith * 506167802Sjkim * PARAMETERS: Node - Device node 507167802Sjkim * RetBuffer - Pointer to a buffer structure for the 508167802Sjkim * results 50967754Smsmith * 51077424Smsmith * RETURN: Status 51167754Smsmith * 51267754Smsmith * DESCRIPTION: This function is called to get the _PRT value of an object 51367754Smsmith * contained in an object specified by the handle passed in 51467754Smsmith * 51567754Smsmith * If the function fails an appropriate status will be returned 51667754Smsmith * and the contents of the callers buffer is undefined. 51767754Smsmith * 51867754Smsmith ******************************************************************************/ 51967754Smsmith 52067754SmsmithACPI_STATUS 52167754SmsmithAcpiRsGetPrtMethodData ( 522167802Sjkim ACPI_NAMESPACE_NODE *Node, 52367754Smsmith ACPI_BUFFER *RetBuffer) 52467754Smsmith{ 52599679Siwasaki ACPI_OPERAND_OBJECT *ObjDesc; 52667754Smsmith ACPI_STATUS Status; 52767754Smsmith 52867754Smsmith 529167802Sjkim ACPI_FUNCTION_TRACE (RsGetPrtMethodData); 53067754Smsmith 53167754Smsmith 53291116Smsmith /* Parameters guaranteed valid by caller */ 53367754Smsmith 534151937Sjkim /* Execute the method, no parameters */ 535151937Sjkim 536306536Sjkim Status = AcpiUtEvaluateObject ( 537306536Sjkim Node, METHOD_NAME__PRT, ACPI_BTYPE_PACKAGE, &ObjDesc); 53867754Smsmith if (ACPI_FAILURE (Status)) 53967754Smsmith { 54067754Smsmith return_ACPI_STATUS (Status); 54167754Smsmith } 54267754Smsmith 54367754Smsmith /* 54491116Smsmith * Create a resource linked list from the byte stream buffer that comes 54591116Smsmith * back from the _CRS method execution. 54667754Smsmith */ 54799679Siwasaki Status = AcpiRsCreatePciRoutingTable (ObjDesc, RetBuffer); 54867754Smsmith 54991116Smsmith /* On exit, we must delete the object returned by EvaluateObject */ 55067754Smsmith 55199679Siwasaki AcpiUtRemoveReference (ObjDesc); 55267754Smsmith return_ACPI_STATUS (Status); 55367754Smsmith} 55467754Smsmith 55567754Smsmith 55667754Smsmith/******************************************************************************* 55767754Smsmith * 55867754Smsmith * FUNCTION: AcpiRsGetCrsMethodData 55967754Smsmith * 560167802Sjkim * PARAMETERS: Node - Device node 561167802Sjkim * RetBuffer - Pointer to a buffer structure for the 562167802Sjkim * results 56367754Smsmith * 56477424Smsmith * RETURN: Status 56567754Smsmith * 56667754Smsmith * DESCRIPTION: This function is called to get the _CRS value of an object 56767754Smsmith * contained in an object specified by the handle passed in 56867754Smsmith * 56967754Smsmith * If the function fails an appropriate status will be returned 57067754Smsmith * and the contents of the callers buffer is undefined. 57167754Smsmith * 57267754Smsmith ******************************************************************************/ 57367754Smsmith 57467754SmsmithACPI_STATUS 57567754SmsmithAcpiRsGetCrsMethodData ( 576167802Sjkim ACPI_NAMESPACE_NODE *Node, 57767754Smsmith ACPI_BUFFER *RetBuffer) 57867754Smsmith{ 57999679Siwasaki ACPI_OPERAND_OBJECT *ObjDesc; 58067754Smsmith ACPI_STATUS Status; 58167754Smsmith 58267754Smsmith 583167802Sjkim ACPI_FUNCTION_TRACE (RsGetCrsMethodData); 58467754Smsmith 58567754Smsmith 58691116Smsmith /* Parameters guaranteed valid by caller */ 58767754Smsmith 588151937Sjkim /* Execute the method, no parameters */ 589151937Sjkim 590306536Sjkim Status = AcpiUtEvaluateObject ( 591306536Sjkim Node, METHOD_NAME__CRS, ACPI_BTYPE_BUFFER, &ObjDesc); 59267754Smsmith if (ACPI_FAILURE (Status)) 59367754Smsmith { 59467754Smsmith return_ACPI_STATUS (Status); 59567754Smsmith } 59667754Smsmith 59767754Smsmith /* 59867754Smsmith * Make the call to create a resource linked list from the 59991116Smsmith * byte stream buffer that comes back from the _CRS method 60091116Smsmith * execution. 60167754Smsmith */ 60299679Siwasaki Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); 60367754Smsmith 60467754Smsmith /* On exit, we must delete the object returned by evaluateObject */ 60567754Smsmith 60699679Siwasaki AcpiUtRemoveReference (ObjDesc); 60767754Smsmith return_ACPI_STATUS (Status); 60867754Smsmith} 60967754Smsmith 61067754Smsmith 61167754Smsmith/******************************************************************************* 61267754Smsmith * 61367754Smsmith * FUNCTION: AcpiRsGetPrsMethodData 61467754Smsmith * 615167802Sjkim * PARAMETERS: Node - Device node 616167802Sjkim * RetBuffer - Pointer to a buffer structure for the 617167802Sjkim * results 61867754Smsmith * 61977424Smsmith * RETURN: Status 62067754Smsmith * 62167754Smsmith * DESCRIPTION: This function is called to get the _PRS value of an object 62267754Smsmith * contained in an object specified by the handle passed in 62367754Smsmith * 62467754Smsmith * If the function fails an appropriate status will be returned 62567754Smsmith * and the contents of the callers buffer is undefined. 62667754Smsmith * 62767754Smsmith ******************************************************************************/ 62867754Smsmith 62967754SmsmithACPI_STATUS 63067754SmsmithAcpiRsGetPrsMethodData ( 631167802Sjkim ACPI_NAMESPACE_NODE *Node, 63267754Smsmith ACPI_BUFFER *RetBuffer) 63367754Smsmith{ 63499679Siwasaki ACPI_OPERAND_OBJECT *ObjDesc; 63567754Smsmith ACPI_STATUS Status; 63667754Smsmith 63767754Smsmith 638167802Sjkim ACPI_FUNCTION_TRACE (RsGetPrsMethodData); 63967754Smsmith 64067754Smsmith 64191116Smsmith /* Parameters guaranteed valid by caller */ 64267754Smsmith 643151937Sjkim /* Execute the method, no parameters */ 644151937Sjkim 645306536Sjkim Status = AcpiUtEvaluateObject ( 646306536Sjkim Node, METHOD_NAME__PRS, ACPI_BTYPE_BUFFER, &ObjDesc); 64767754Smsmith if (ACPI_FAILURE (Status)) 64867754Smsmith { 64967754Smsmith return_ACPI_STATUS (Status); 65067754Smsmith } 65167754Smsmith 652114237Snjl /* 653114237Snjl * Make the call to create a resource linked list from the 654114237Snjl * byte stream buffer that comes back from the _CRS method 655114237Snjl * execution. 656114237Snjl */ 657114237Snjl Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); 65867754Smsmith 659114237Snjl /* On exit, we must delete the object returned by evaluateObject */ 66067754Smsmith 661114237Snjl AcpiUtRemoveReference (ObjDesc); 662114237Snjl return_ACPI_STATUS (Status); 663114237Snjl} 664114237Snjl 665114237Snjl 666114237Snjl/******************************************************************************* 667114237Snjl * 668228110Sjkim * FUNCTION: AcpiRsGetAeiMethodData 669228110Sjkim * 670228110Sjkim * PARAMETERS: Node - Device node 671228110Sjkim * RetBuffer - Pointer to a buffer structure for the 672228110Sjkim * results 673228110Sjkim * 674228110Sjkim * RETURN: Status 675228110Sjkim * 676228110Sjkim * DESCRIPTION: This function is called to get the _AEI value of an object 677228110Sjkim * contained in an object specified by the handle passed in 678228110Sjkim * 679228110Sjkim * If the function fails an appropriate status will be returned 680228110Sjkim * and the contents of the callers buffer is undefined. 681228110Sjkim * 682228110Sjkim ******************************************************************************/ 683228110Sjkim 684228110SjkimACPI_STATUS 685228110SjkimAcpiRsGetAeiMethodData ( 686228110Sjkim ACPI_NAMESPACE_NODE *Node, 687228110Sjkim ACPI_BUFFER *RetBuffer) 688228110Sjkim{ 689228110Sjkim ACPI_OPERAND_OBJECT *ObjDesc; 690228110Sjkim ACPI_STATUS Status; 691228110Sjkim 692228110Sjkim 693228110Sjkim ACPI_FUNCTION_TRACE (RsGetAeiMethodData); 694228110Sjkim 695228110Sjkim 696228110Sjkim /* Parameters guaranteed valid by caller */ 697228110Sjkim 698228110Sjkim /* Execute the method, no parameters */ 699228110Sjkim 700306536Sjkim Status = AcpiUtEvaluateObject ( 701306536Sjkim Node, METHOD_NAME__AEI, ACPI_BTYPE_BUFFER, &ObjDesc); 702228110Sjkim if (ACPI_FAILURE (Status)) 703228110Sjkim { 704228110Sjkim return_ACPI_STATUS (Status); 705228110Sjkim } 706228110Sjkim 707228110Sjkim /* 708228110Sjkim * Make the call to create a resource linked list from the 709228110Sjkim * byte stream buffer that comes back from the _CRS method 710228110Sjkim * execution. 711228110Sjkim */ 712228110Sjkim Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); 713228110Sjkim 714228110Sjkim /* On exit, we must delete the object returned by evaluateObject */ 715228110Sjkim 716228110Sjkim AcpiUtRemoveReference (ObjDesc); 717228110Sjkim return_ACPI_STATUS (Status); 718228110Sjkim} 719228110Sjkim 720228110Sjkim 721228110Sjkim/******************************************************************************* 722228110Sjkim * 723114237Snjl * FUNCTION: AcpiRsGetMethodData 724114237Snjl * 725167802Sjkim * PARAMETERS: Handle - Handle to the containing object 726151937Sjkim * Path - Path to method, relative to Handle 727167802Sjkim * RetBuffer - Pointer to a buffer structure for the 728167802Sjkim * results 729114237Snjl * 730114237Snjl * RETURN: Status 731114237Snjl * 732114237Snjl * DESCRIPTION: This function is called to get the _CRS or _PRS value of an 733114237Snjl * object contained in an object specified by the handle passed in 734114237Snjl * 735114237Snjl * If the function fails an appropriate status will be returned 736114237Snjl * and the contents of the callers buffer is undefined. 737114237Snjl * 738114237Snjl ******************************************************************************/ 739114237Snjl 740114237SnjlACPI_STATUS 741114237SnjlAcpiRsGetMethodData ( 742114237Snjl ACPI_HANDLE Handle, 743306536Sjkim const char *Path, 744114237Snjl ACPI_BUFFER *RetBuffer) 745114237Snjl{ 746114237Snjl ACPI_OPERAND_OBJECT *ObjDesc; 747114237Snjl ACPI_STATUS Status; 748114237Snjl 749114237Snjl 750167802Sjkim ACPI_FUNCTION_TRACE (RsGetMethodData); 751114237Snjl 752114237Snjl 753114237Snjl /* Parameters guaranteed valid by caller */ 754114237Snjl 755151937Sjkim /* Execute the method, no parameters */ 756151937Sjkim 757306536Sjkim Status = AcpiUtEvaluateObject ( 758306536Sjkim ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Handle), 759245582Sjkim Path, ACPI_BTYPE_BUFFER, &ObjDesc); 760167802Sjkim if (ACPI_FAILURE (Status)) 761167802Sjkim { 762114237Snjl return_ACPI_STATUS (Status); 76367754Smsmith } 76467754Smsmith 76567754Smsmith /* 76667754Smsmith * Make the call to create a resource linked list from the 767114237Snjl * byte stream buffer that comes back from the method 76891116Smsmith * execution. 76967754Smsmith */ 77099679Siwasaki Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); 77167754Smsmith 772114237Snjl /* On exit, we must delete the object returned by EvaluateObject */ 77367754Smsmith 77499679Siwasaki AcpiUtRemoveReference (ObjDesc); 77567754Smsmith return_ACPI_STATUS (Status); 77667754Smsmith} 77767754Smsmith 778167802Sjkim 77967754Smsmith/******************************************************************************* 78067754Smsmith * 78167754Smsmith * FUNCTION: AcpiRsSetSrsMethodData 78267754Smsmith * 783167802Sjkim * PARAMETERS: Node - Device node 784167802Sjkim * InBuffer - Pointer to a buffer structure of the 785167802Sjkim * parameter 78667754Smsmith * 78777424Smsmith * RETURN: Status 78867754Smsmith * 78967754Smsmith * DESCRIPTION: This function is called to set the _SRS of an object contained 79067754Smsmith * in an object specified by the handle passed in 79167754Smsmith * 79267754Smsmith * If the function fails an appropriate status will be returned 79367754Smsmith * and the contents of the callers buffer is undefined. 79467754Smsmith * 795167802Sjkim * Note: Parameters guaranteed valid by caller 796167802Sjkim * 79767754Smsmith ******************************************************************************/ 79867754Smsmith 79967754SmsmithACPI_STATUS 80067754SmsmithAcpiRsSetSrsMethodData ( 801167802Sjkim ACPI_NAMESPACE_NODE *Node, 80267754Smsmith ACPI_BUFFER *InBuffer) 80367754Smsmith{ 804167802Sjkim ACPI_EVALUATE_INFO *Info; 805167802Sjkim ACPI_OPERAND_OBJECT *Args[2]; 80667754Smsmith ACPI_STATUS Status; 80791116Smsmith ACPI_BUFFER Buffer; 80867754Smsmith 80967754Smsmith 810167802Sjkim ACPI_FUNCTION_TRACE (RsSetSrsMethodData); 81167754Smsmith 81267754Smsmith 813167802Sjkim /* Allocate and initialize the evaluation information block */ 81467754Smsmith 815167802Sjkim Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); 816167802Sjkim if (!Info) 817167802Sjkim { 818167802Sjkim return_ACPI_STATUS (AE_NO_MEMORY); 819167802Sjkim } 820167802Sjkim 821167802Sjkim Info->PrefixNode = Node; 822249663Sjkim Info->RelativePathname = METHOD_NAME__SRS; 823167802Sjkim Info->Parameters = Args; 824167802Sjkim Info->Flags = ACPI_IGNORE_RETURN_VALUE; 825167802Sjkim 82667754Smsmith /* 82767754Smsmith * The InBuffer parameter will point to a linked list of 828167802Sjkim * resource parameters. It needs to be formatted into a 82991116Smsmith * byte stream to be sent in as an input parameter to _SRS 83091116Smsmith * 83191116Smsmith * Convert the linked list into a byte stream 83267754Smsmith */ 83391116Smsmith Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 834281075Sdim Status = AcpiRsCreateAmlResources (InBuffer, &Buffer); 83591116Smsmith if (ACPI_FAILURE (Status)) 83667754Smsmith { 837167802Sjkim goto Cleanup; 83867754Smsmith } 83967754Smsmith 840167802Sjkim /* Create and initialize the method parameter object */ 841151937Sjkim 842167802Sjkim Args[0] = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); 843167802Sjkim if (!Args[0]) 84484491Smsmith { 845167802Sjkim /* 846167802Sjkim * Must free the buffer allocated above (otherwise it is freed 847167802Sjkim * later) 848167802Sjkim */ 849167802Sjkim ACPI_FREE (Buffer.Pointer); 850167802Sjkim Status = AE_NO_MEMORY; 851167802Sjkim goto Cleanup; 85284491Smsmith } 85367754Smsmith 854167802Sjkim Args[0]->Buffer.Length = (UINT32) Buffer.Length; 855167802Sjkim Args[0]->Buffer.Pointer = Buffer.Pointer; 856167802Sjkim Args[0]->Common.Flags = AOPOBJ_DATA_VALID; 857167802Sjkim Args[1] = NULL; 858151937Sjkim 859167802Sjkim /* Execute the method, no return value is expected */ 86067754Smsmith 861167802Sjkim Status = AcpiNsEvaluate (Info); 862129684Snjl 863167802Sjkim /* Clean up and return the status from AcpiNsEvaluate */ 86467754Smsmith 865167802Sjkim AcpiUtRemoveReference (Args[0]); 866151937Sjkim 867167802SjkimCleanup: 868167802Sjkim ACPI_FREE (Info); 86967754Smsmith return_ACPI_STATUS (Status); 87067754Smsmith} 871