rsutils.c revision 217365
167754Smsmith/******************************************************************************* 267754Smsmith * 367754Smsmith * Module Name: rsutils - Utilities for the resource manager 467754Smsmith * 567754Smsmith ******************************************************************************/ 667754Smsmith 7217365Sjkim/* 8217365Sjkim * Copyright (C) 2000 - 2011, 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 4467754Smsmith 4567754Smsmith#define __RSUTILS_C__ 4667754Smsmith 47193341Sjkim#include <contrib/dev/acpica/include/acpi.h> 48193341Sjkim#include <contrib/dev/acpica/include/accommon.h> 49193341Sjkim#include <contrib/dev/acpica/include/acnamesp.h> 50193341Sjkim#include <contrib/dev/acpica/include/acresrc.h> 5167754Smsmith 5267754Smsmith 5377424Smsmith#define _COMPONENT ACPI_RESOURCES 5491116Smsmith ACPI_MODULE_NAME ("rsutils") 5567754Smsmith 5667754Smsmith 5767754Smsmith/******************************************************************************* 5867754Smsmith * 59151937Sjkim * FUNCTION: AcpiRsDecodeBitmask 60151937Sjkim * 61151937Sjkim * PARAMETERS: Mask - Bitmask to decode 62151937Sjkim * List - Where the converted list is returned 63151937Sjkim * 64151937Sjkim * RETURN: Count of bits set (length of list) 65151937Sjkim * 66151937Sjkim * DESCRIPTION: Convert a bit mask into a list of values 67151937Sjkim * 68151937Sjkim ******************************************************************************/ 69151937Sjkim 70151937SjkimUINT8 71151937SjkimAcpiRsDecodeBitmask ( 72151937Sjkim UINT16 Mask, 73151937Sjkim UINT8 *List) 74151937Sjkim{ 75193267Sjkim UINT8 i; 76151937Sjkim UINT8 BitCount; 77151937Sjkim 78151937Sjkim 79167802Sjkim ACPI_FUNCTION_ENTRY (); 80167802Sjkim 81167802Sjkim 82151937Sjkim /* Decode the mask bits */ 83151937Sjkim 84151937Sjkim for (i = 0, BitCount = 0; Mask; i++) 85151937Sjkim { 86151937Sjkim if (Mask & 0x0001) 87151937Sjkim { 88193267Sjkim List[BitCount] = i; 89151937Sjkim BitCount++; 90151937Sjkim } 91151937Sjkim 92151937Sjkim Mask >>= 1; 93151937Sjkim } 94151937Sjkim 95151937Sjkim return (BitCount); 96151937Sjkim} 97151937Sjkim 98151937Sjkim 99151937Sjkim/******************************************************************************* 100151937Sjkim * 101151937Sjkim * FUNCTION: AcpiRsEncodeBitmask 102151937Sjkim * 103151937Sjkim * PARAMETERS: List - List of values to encode 104151937Sjkim * Count - Length of list 105151937Sjkim * 106151937Sjkim * RETURN: Encoded bitmask 107151937Sjkim * 108151937Sjkim * DESCRIPTION: Convert a list of values to an encoded bitmask 109151937Sjkim * 110151937Sjkim ******************************************************************************/ 111151937Sjkim 112151937SjkimUINT16 113151937SjkimAcpiRsEncodeBitmask ( 114151937Sjkim UINT8 *List, 115151937Sjkim UINT8 Count) 116151937Sjkim{ 117193267Sjkim UINT32 i; 118151937Sjkim UINT16 Mask; 119151937Sjkim 120151937Sjkim 121167802Sjkim ACPI_FUNCTION_ENTRY (); 122167802Sjkim 123167802Sjkim 124151937Sjkim /* Encode the list into a single bitmask */ 125151937Sjkim 126151937Sjkim for (i = 0, Mask = 0; i < Count; i++) 127151937Sjkim { 128193267Sjkim Mask |= (0x1 << List[i]); 129151937Sjkim } 130151937Sjkim 131151937Sjkim return (Mask); 132151937Sjkim} 133151937Sjkim 134151937Sjkim 135151937Sjkim/******************************************************************************* 136151937Sjkim * 137151937Sjkim * FUNCTION: AcpiRsMoveData 138151937Sjkim * 139151937Sjkim * PARAMETERS: Destination - Pointer to the destination descriptor 140151937Sjkim * Source - Pointer to the source descriptor 141151937Sjkim * ItemCount - How many items to move 142151937Sjkim * MoveType - Byte width 143151937Sjkim * 144151937Sjkim * RETURN: None 145151937Sjkim * 146151937Sjkim * DESCRIPTION: Move multiple data items from one descriptor to another. Handles 147151937Sjkim * alignment issues and endian issues if necessary, as configured 148151937Sjkim * via the ACPI_MOVE_* macros. (This is why a memcpy is not used) 149151937Sjkim * 150151937Sjkim ******************************************************************************/ 151151937Sjkim 152151937Sjkimvoid 153151937SjkimAcpiRsMoveData ( 154151937Sjkim void *Destination, 155151937Sjkim void *Source, 156151937Sjkim UINT16 ItemCount, 157151937Sjkim UINT8 MoveType) 158151937Sjkim{ 159193267Sjkim UINT32 i; 160151937Sjkim 161151937Sjkim 162167802Sjkim ACPI_FUNCTION_ENTRY (); 163167802Sjkim 164167802Sjkim 165151937Sjkim /* One move per item */ 166151937Sjkim 167151937Sjkim for (i = 0; i < ItemCount; i++) 168151937Sjkim { 169151937Sjkim switch (MoveType) 170151937Sjkim { 171151937Sjkim /* 172151937Sjkim * For the 8-bit case, we can perform the move all at once 173151937Sjkim * since there are no alignment or endian issues 174151937Sjkim */ 175151937Sjkim case ACPI_RSC_MOVE8: 176151937Sjkim ACPI_MEMCPY (Destination, Source, ItemCount); 177151937Sjkim return; 178151937Sjkim 179151937Sjkim /* 180151937Sjkim * 16-, 32-, and 64-bit cases must use the move macros that perform 181151937Sjkim * endian conversion and/or accomodate hardware that cannot perform 182151937Sjkim * misaligned memory transfers 183151937Sjkim */ 184151937Sjkim case ACPI_RSC_MOVE16: 185167802Sjkim ACPI_MOVE_16_TO_16 (&ACPI_CAST_PTR (UINT16, Destination)[i], 186167802Sjkim &ACPI_CAST_PTR (UINT16, Source)[i]); 187151937Sjkim break; 188151937Sjkim 189151937Sjkim case ACPI_RSC_MOVE32: 190167802Sjkim ACPI_MOVE_32_TO_32 (&ACPI_CAST_PTR (UINT32, Destination)[i], 191167802Sjkim &ACPI_CAST_PTR (UINT32, Source)[i]); 192151937Sjkim break; 193151937Sjkim 194151937Sjkim case ACPI_RSC_MOVE64: 195167802Sjkim ACPI_MOVE_64_TO_64 (&ACPI_CAST_PTR (UINT64, Destination)[i], 196167802Sjkim &ACPI_CAST_PTR (UINT64, Source)[i]); 197151937Sjkim break; 198151937Sjkim 199151937Sjkim default: 200151937Sjkim return; 201151937Sjkim } 202151937Sjkim } 203151937Sjkim} 204151937Sjkim 205151937Sjkim 206151937Sjkim/******************************************************************************* 207151937Sjkim * 208151937Sjkim * FUNCTION: AcpiRsSetResourceLength 209151937Sjkim * 210151937Sjkim * PARAMETERS: TotalLength - Length of the AML descriptor, including 211151937Sjkim * the header and length fields. 212151937Sjkim * Aml - Pointer to the raw AML descriptor 213151937Sjkim * 214151937Sjkim * RETURN: None 215151937Sjkim * 216151937Sjkim * DESCRIPTION: Set the ResourceLength field of an AML 217151937Sjkim * resource descriptor, both Large and Small descriptors are 218151937Sjkim * supported automatically. Note: Descriptor Type field must 219151937Sjkim * be valid. 220151937Sjkim * 221151937Sjkim ******************************************************************************/ 222151937Sjkim 223151937Sjkimvoid 224151937SjkimAcpiRsSetResourceLength ( 225151937Sjkim ACPI_RSDESC_SIZE TotalLength, 226151937Sjkim AML_RESOURCE *Aml) 227151937Sjkim{ 228151937Sjkim ACPI_RS_LENGTH ResourceLength; 229151937Sjkim 230151937Sjkim 231151937Sjkim ACPI_FUNCTION_ENTRY (); 232151937Sjkim 233151937Sjkim 234167802Sjkim /* Length is the total descriptor length minus the header length */ 235151937Sjkim 236167802Sjkim ResourceLength = (ACPI_RS_LENGTH) 237167802Sjkim (TotalLength - AcpiUtGetResourceHeaderLength (Aml)); 238167802Sjkim 239167802Sjkim /* Length is stored differently for large and small descriptors */ 240167802Sjkim 241151937Sjkim if (Aml->SmallHeader.DescriptorType & ACPI_RESOURCE_NAME_LARGE) 242151937Sjkim { 243167802Sjkim /* Large descriptor -- bytes 1-2 contain the 16-bit length */ 244151937Sjkim 245151937Sjkim ACPI_MOVE_16_TO_16 (&Aml->LargeHeader.ResourceLength, &ResourceLength); 246151937Sjkim } 247151937Sjkim else 248151937Sjkim { 249167802Sjkim /* Small descriptor -- bits 2:0 of byte 0 contain the length */ 250151937Sjkim 251151937Sjkim Aml->SmallHeader.DescriptorType = (UINT8) 252151937Sjkim 253151937Sjkim /* Clear any existing length, preserving descriptor type bits */ 254151937Sjkim 255151937Sjkim ((Aml->SmallHeader.DescriptorType & ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK) 256151937Sjkim 257151937Sjkim | ResourceLength); 258151937Sjkim } 259151937Sjkim} 260151937Sjkim 261151937Sjkim 262151937Sjkim/******************************************************************************* 263151937Sjkim * 264151937Sjkim * FUNCTION: AcpiRsSetResourceHeader 265151937Sjkim * 266151937Sjkim * PARAMETERS: DescriptorType - Byte to be inserted as the type 267151937Sjkim * TotalLength - Length of the AML descriptor, including 268151937Sjkim * the header and length fields. 269151937Sjkim * Aml - Pointer to the raw AML descriptor 270151937Sjkim * 271151937Sjkim * RETURN: None 272151937Sjkim * 273151937Sjkim * DESCRIPTION: Set the DescriptorType and ResourceLength fields of an AML 274151937Sjkim * resource descriptor, both Large and Small descriptors are 275151937Sjkim * supported automatically 276151937Sjkim * 277151937Sjkim ******************************************************************************/ 278151937Sjkim 279151937Sjkimvoid 280151937SjkimAcpiRsSetResourceHeader ( 281151937Sjkim UINT8 DescriptorType, 282151937Sjkim ACPI_RSDESC_SIZE TotalLength, 283151937Sjkim AML_RESOURCE *Aml) 284151937Sjkim{ 285151937Sjkim ACPI_FUNCTION_ENTRY (); 286151937Sjkim 287151937Sjkim 288167802Sjkim /* Set the Resource Type */ 289151937Sjkim 290151937Sjkim Aml->SmallHeader.DescriptorType = DescriptorType; 291151937Sjkim 292151937Sjkim /* Set the Resource Length */ 293151937Sjkim 294151937Sjkim AcpiRsSetResourceLength (TotalLength, Aml); 295151937Sjkim} 296151937Sjkim 297151937Sjkim 298151937Sjkim/******************************************************************************* 299151937Sjkim * 300151937Sjkim * FUNCTION: AcpiRsStrcpy 301151937Sjkim * 302151937Sjkim * PARAMETERS: Destination - Pointer to the destination string 303151937Sjkim * Source - Pointer to the source string 304151937Sjkim * 305151937Sjkim * RETURN: String length, including NULL terminator 306151937Sjkim * 307151937Sjkim * DESCRIPTION: Local string copy that returns the string length, saving a 308151937Sjkim * strcpy followed by a strlen. 309151937Sjkim * 310151937Sjkim ******************************************************************************/ 311151937Sjkim 312151937Sjkimstatic UINT16 313151937SjkimAcpiRsStrcpy ( 314151937Sjkim char *Destination, 315151937Sjkim char *Source) 316151937Sjkim{ 317151937Sjkim UINT16 i; 318151937Sjkim 319151937Sjkim 320151937Sjkim ACPI_FUNCTION_ENTRY (); 321151937Sjkim 322151937Sjkim 323151937Sjkim for (i = 0; Source[i]; i++) 324151937Sjkim { 325151937Sjkim Destination[i] = Source[i]; 326151937Sjkim } 327151937Sjkim 328151937Sjkim Destination[i] = 0; 329151937Sjkim 330151937Sjkim /* Return string length including the NULL terminator */ 331151937Sjkim 332151937Sjkim return ((UINT16) (i + 1)); 333151937Sjkim} 334151937Sjkim 335151937Sjkim 336151937Sjkim/******************************************************************************* 337151937Sjkim * 338151937Sjkim * FUNCTION: AcpiRsGetResourceSource 339151937Sjkim * 340151937Sjkim * PARAMETERS: ResourceLength - Length field of the descriptor 341151937Sjkim * MinimumLength - Minimum length of the descriptor (minus 342151937Sjkim * any optional fields) 343151937Sjkim * ResourceSource - Where the ResourceSource is returned 344151937Sjkim * Aml - Pointer to the raw AML descriptor 345151937Sjkim * StringPtr - (optional) where to store the actual 346151937Sjkim * ResourceSource string 347151937Sjkim * 348167802Sjkim * RETURN: Length of the string plus NULL terminator, rounded up to native 349167802Sjkim * word boundary 350151937Sjkim * 351151937Sjkim * DESCRIPTION: Copy the optional ResourceSource data from a raw AML descriptor 352151937Sjkim * to an internal resource descriptor 353151937Sjkim * 354151937Sjkim ******************************************************************************/ 355151937Sjkim 356151937SjkimACPI_RS_LENGTH 357151937SjkimAcpiRsGetResourceSource ( 358151937Sjkim ACPI_RS_LENGTH ResourceLength, 359151937Sjkim ACPI_RS_LENGTH MinimumLength, 360151937Sjkim ACPI_RESOURCE_SOURCE *ResourceSource, 361151937Sjkim AML_RESOURCE *Aml, 362151937Sjkim char *StringPtr) 363151937Sjkim{ 364151937Sjkim ACPI_RSDESC_SIZE TotalLength; 365151937Sjkim UINT8 *AmlResourceSource; 366151937Sjkim 367151937Sjkim 368151937Sjkim ACPI_FUNCTION_ENTRY (); 369151937Sjkim 370151937Sjkim 371151937Sjkim TotalLength = ResourceLength + sizeof (AML_RESOURCE_LARGE_HEADER); 372167802Sjkim AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength); 373151937Sjkim 374151937Sjkim /* 375151937Sjkim * ResourceSource is present if the length of the descriptor is longer than 376151937Sjkim * the minimum length. 377151937Sjkim * 378151937Sjkim * Note: Some resource descriptors will have an additional null, so 379151937Sjkim * we add 1 to the minimum length. 380151937Sjkim */ 381167802Sjkim if (TotalLength > (ACPI_RSDESC_SIZE) (MinimumLength + 1)) 382151937Sjkim { 383151937Sjkim /* Get the ResourceSourceIndex */ 384151937Sjkim 385151937Sjkim ResourceSource->Index = AmlResourceSource[0]; 386151937Sjkim 387151937Sjkim ResourceSource->StringPtr = StringPtr; 388151937Sjkim if (!StringPtr) 389151937Sjkim { 390151937Sjkim /* 391151937Sjkim * String destination pointer is not specified; Set the String 392151937Sjkim * pointer to the end of the current ResourceSource structure. 393151937Sjkim */ 394167802Sjkim ResourceSource->StringPtr = ACPI_ADD_PTR (char, ResourceSource, 395167802Sjkim sizeof (ACPI_RESOURCE_SOURCE)); 396151937Sjkim } 397151937Sjkim 398151937Sjkim /* 399167802Sjkim * In order for the Resource length to be a multiple of the native 400167802Sjkim * word, calculate the length of the string (+1 for NULL terminator) 401167802Sjkim * and expand to the next word multiple. 402151937Sjkim * 403151937Sjkim * Zero the entire area of the buffer. 404151937Sjkim */ 405167802Sjkim TotalLength = (UINT32) ACPI_STRLEN ( 406167802Sjkim ACPI_CAST_PTR (char, &AmlResourceSource[1])) + 1; 407167802Sjkim TotalLength = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (TotalLength); 408167802Sjkim 409151937Sjkim ACPI_MEMSET (ResourceSource->StringPtr, 0, TotalLength); 410151937Sjkim 411151937Sjkim /* Copy the ResourceSource string to the destination */ 412151937Sjkim 413151937Sjkim ResourceSource->StringLength = AcpiRsStrcpy (ResourceSource->StringPtr, 414167802Sjkim ACPI_CAST_PTR (char, &AmlResourceSource[1])); 415151937Sjkim 416151937Sjkim return ((ACPI_RS_LENGTH) TotalLength); 417151937Sjkim } 418151937Sjkim 419167802Sjkim /* ResourceSource is not present */ 420167802Sjkim 421167802Sjkim ResourceSource->Index = 0; 422167802Sjkim ResourceSource->StringLength = 0; 423167802Sjkim ResourceSource->StringPtr = NULL; 424167802Sjkim return (0); 425151937Sjkim} 426151937Sjkim 427167802Sjkim 428151937Sjkim/******************************************************************************* 429151937Sjkim * 430151937Sjkim * FUNCTION: AcpiRsSetResourceSource 431151937Sjkim * 432151937Sjkim * PARAMETERS: Aml - Pointer to the raw AML descriptor 433151937Sjkim * MinimumLength - Minimum length of the descriptor (minus 434151937Sjkim * any optional fields) 435151937Sjkim * ResourceSource - Internal ResourceSource 436151937Sjkim 437151937Sjkim * 438151937Sjkim * RETURN: Total length of the AML descriptor 439151937Sjkim * 440151937Sjkim * DESCRIPTION: Convert an optional ResourceSource from internal format to a 441151937Sjkim * raw AML resource descriptor 442151937Sjkim * 443151937Sjkim ******************************************************************************/ 444151937Sjkim 445151937SjkimACPI_RSDESC_SIZE 446151937SjkimAcpiRsSetResourceSource ( 447151937Sjkim AML_RESOURCE *Aml, 448151937Sjkim ACPI_RS_LENGTH MinimumLength, 449151937Sjkim ACPI_RESOURCE_SOURCE *ResourceSource) 450151937Sjkim{ 451151937Sjkim UINT8 *AmlResourceSource; 452151937Sjkim ACPI_RSDESC_SIZE DescriptorLength; 453151937Sjkim 454151937Sjkim 455151937Sjkim ACPI_FUNCTION_ENTRY (); 456151937Sjkim 457151937Sjkim 458151937Sjkim DescriptorLength = MinimumLength; 459151937Sjkim 460151937Sjkim /* Non-zero string length indicates presence of a ResourceSource */ 461151937Sjkim 462151937Sjkim if (ResourceSource->StringLength) 463151937Sjkim { 464151937Sjkim /* Point to the end of the AML descriptor */ 465151937Sjkim 466167802Sjkim AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength); 467151937Sjkim 468151937Sjkim /* Copy the ResourceSourceIndex */ 469151937Sjkim 470151937Sjkim AmlResourceSource[0] = (UINT8) ResourceSource->Index; 471151937Sjkim 472151937Sjkim /* Copy the ResourceSource string */ 473151937Sjkim 474167802Sjkim ACPI_STRCPY (ACPI_CAST_PTR (char, &AmlResourceSource[1]), 475167802Sjkim ResourceSource->StringPtr); 476151937Sjkim 477151937Sjkim /* 478151937Sjkim * Add the length of the string (+ 1 for null terminator) to the 479151937Sjkim * final descriptor length 480151937Sjkim */ 481151937Sjkim DescriptorLength += ((ACPI_RSDESC_SIZE) ResourceSource->StringLength + 1); 482151937Sjkim } 483151937Sjkim 484151937Sjkim /* Return the new total length of the AML descriptor */ 485151937Sjkim 486151937Sjkim return (DescriptorLength); 487151937Sjkim} 488151937Sjkim 489151937Sjkim 490151937Sjkim/******************************************************************************* 491151937Sjkim * 49267754Smsmith * FUNCTION: AcpiRsGetPrtMethodData 49367754Smsmith * 494167802Sjkim * PARAMETERS: Node - Device node 495167802Sjkim * RetBuffer - Pointer to a buffer structure for the 496167802Sjkim * results 49767754Smsmith * 49877424Smsmith * RETURN: Status 49967754Smsmith * 50067754Smsmith * DESCRIPTION: This function is called to get the _PRT value of an object 50167754Smsmith * contained in an object specified by the handle passed in 50267754Smsmith * 50367754Smsmith * If the function fails an appropriate status will be returned 50467754Smsmith * and the contents of the callers buffer is undefined. 50567754Smsmith * 50667754Smsmith ******************************************************************************/ 50767754Smsmith 50867754SmsmithACPI_STATUS 50967754SmsmithAcpiRsGetPrtMethodData ( 510167802Sjkim ACPI_NAMESPACE_NODE *Node, 51167754Smsmith ACPI_BUFFER *RetBuffer) 51267754Smsmith{ 51399679Siwasaki ACPI_OPERAND_OBJECT *ObjDesc; 51467754Smsmith ACPI_STATUS Status; 51567754Smsmith 51667754Smsmith 517167802Sjkim ACPI_FUNCTION_TRACE (RsGetPrtMethodData); 51867754Smsmith 51967754Smsmith 52091116Smsmith /* Parameters guaranteed valid by caller */ 52167754Smsmith 522151937Sjkim /* Execute the method, no parameters */ 523151937Sjkim 524167802Sjkim Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRT, 525151937Sjkim ACPI_BTYPE_PACKAGE, &ObjDesc); 52667754Smsmith if (ACPI_FAILURE (Status)) 52767754Smsmith { 52867754Smsmith return_ACPI_STATUS (Status); 52967754Smsmith } 53067754Smsmith 53167754Smsmith /* 53291116Smsmith * Create a resource linked list from the byte stream buffer that comes 53391116Smsmith * back from the _CRS method execution. 53467754Smsmith */ 53599679Siwasaki Status = AcpiRsCreatePciRoutingTable (ObjDesc, RetBuffer); 53667754Smsmith 53791116Smsmith /* On exit, we must delete the object returned by EvaluateObject */ 53867754Smsmith 53999679Siwasaki AcpiUtRemoveReference (ObjDesc); 54067754Smsmith return_ACPI_STATUS (Status); 54167754Smsmith} 54267754Smsmith 54367754Smsmith 54467754Smsmith/******************************************************************************* 54567754Smsmith * 54667754Smsmith * FUNCTION: AcpiRsGetCrsMethodData 54767754Smsmith * 548167802Sjkim * PARAMETERS: Node - Device node 549167802Sjkim * RetBuffer - Pointer to a buffer structure for the 550167802Sjkim * results 55167754Smsmith * 55277424Smsmith * RETURN: Status 55367754Smsmith * 55467754Smsmith * DESCRIPTION: This function is called to get the _CRS value of an object 55567754Smsmith * contained in an object specified by the handle passed in 55667754Smsmith * 55767754Smsmith * If the function fails an appropriate status will be returned 55867754Smsmith * and the contents of the callers buffer is undefined. 55967754Smsmith * 56067754Smsmith ******************************************************************************/ 56167754Smsmith 56267754SmsmithACPI_STATUS 56367754SmsmithAcpiRsGetCrsMethodData ( 564167802Sjkim ACPI_NAMESPACE_NODE *Node, 56567754Smsmith ACPI_BUFFER *RetBuffer) 56667754Smsmith{ 56799679Siwasaki ACPI_OPERAND_OBJECT *ObjDesc; 56867754Smsmith ACPI_STATUS Status; 56967754Smsmith 57067754Smsmith 571167802Sjkim ACPI_FUNCTION_TRACE (RsGetCrsMethodData); 57267754Smsmith 57367754Smsmith 57491116Smsmith /* Parameters guaranteed valid by caller */ 57567754Smsmith 576151937Sjkim /* Execute the method, no parameters */ 577151937Sjkim 578167802Sjkim Status = AcpiUtEvaluateObject (Node, METHOD_NAME__CRS, 579151937Sjkim ACPI_BTYPE_BUFFER, &ObjDesc); 58067754Smsmith if (ACPI_FAILURE (Status)) 58167754Smsmith { 58267754Smsmith return_ACPI_STATUS (Status); 58367754Smsmith } 58467754Smsmith 58567754Smsmith /* 58667754Smsmith * Make the call to create a resource linked list from the 58791116Smsmith * byte stream buffer that comes back from the _CRS method 58891116Smsmith * execution. 58967754Smsmith */ 59099679Siwasaki Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); 59167754Smsmith 59267754Smsmith /* On exit, we must delete the object returned by evaluateObject */ 59367754Smsmith 59499679Siwasaki AcpiUtRemoveReference (ObjDesc); 59567754Smsmith return_ACPI_STATUS (Status); 59667754Smsmith} 59767754Smsmith 59867754Smsmith 59967754Smsmith/******************************************************************************* 60067754Smsmith * 60167754Smsmith * FUNCTION: AcpiRsGetPrsMethodData 60267754Smsmith * 603167802Sjkim * PARAMETERS: Node - Device node 604167802Sjkim * RetBuffer - Pointer to a buffer structure for the 605167802Sjkim * results 60667754Smsmith * 60777424Smsmith * RETURN: Status 60867754Smsmith * 60967754Smsmith * DESCRIPTION: This function is called to get the _PRS value of an object 61067754Smsmith * contained in an object specified by the handle passed in 61167754Smsmith * 61267754Smsmith * If the function fails an appropriate status will be returned 61367754Smsmith * and the contents of the callers buffer is undefined. 61467754Smsmith * 61567754Smsmith ******************************************************************************/ 61667754Smsmith 61767754SmsmithACPI_STATUS 61867754SmsmithAcpiRsGetPrsMethodData ( 619167802Sjkim ACPI_NAMESPACE_NODE *Node, 62067754Smsmith ACPI_BUFFER *RetBuffer) 62167754Smsmith{ 62299679Siwasaki ACPI_OPERAND_OBJECT *ObjDesc; 62367754Smsmith ACPI_STATUS Status; 62467754Smsmith 62567754Smsmith 626167802Sjkim ACPI_FUNCTION_TRACE (RsGetPrsMethodData); 62767754Smsmith 62867754Smsmith 62991116Smsmith /* Parameters guaranteed valid by caller */ 63067754Smsmith 631151937Sjkim /* Execute the method, no parameters */ 632151937Sjkim 633167802Sjkim Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRS, 634151937Sjkim ACPI_BTYPE_BUFFER, &ObjDesc); 63567754Smsmith if (ACPI_FAILURE (Status)) 63667754Smsmith { 63767754Smsmith return_ACPI_STATUS (Status); 63867754Smsmith } 63967754Smsmith 640114237Snjl /* 641114237Snjl * Make the call to create a resource linked list from the 642114237Snjl * byte stream buffer that comes back from the _CRS method 643114237Snjl * execution. 644114237Snjl */ 645114237Snjl Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); 64667754Smsmith 647114237Snjl /* On exit, we must delete the object returned by evaluateObject */ 64867754Smsmith 649114237Snjl AcpiUtRemoveReference (ObjDesc); 650114237Snjl return_ACPI_STATUS (Status); 651114237Snjl} 652114237Snjl 653114237Snjl 654114237Snjl/******************************************************************************* 655114237Snjl * 656114237Snjl * FUNCTION: AcpiRsGetMethodData 657114237Snjl * 658167802Sjkim * PARAMETERS: Handle - Handle to the containing object 659151937Sjkim * Path - Path to method, relative to Handle 660167802Sjkim * RetBuffer - Pointer to a buffer structure for the 661167802Sjkim * results 662114237Snjl * 663114237Snjl * RETURN: Status 664114237Snjl * 665114237Snjl * DESCRIPTION: This function is called to get the _CRS or _PRS value of an 666114237Snjl * object contained in an object specified by the handle passed in 667114237Snjl * 668114237Snjl * If the function fails an appropriate status will be returned 669114237Snjl * and the contents of the callers buffer is undefined. 670114237Snjl * 671114237Snjl ******************************************************************************/ 672114237Snjl 673114237SnjlACPI_STATUS 674114237SnjlAcpiRsGetMethodData ( 675114237Snjl ACPI_HANDLE Handle, 676114237Snjl char *Path, 677114237Snjl ACPI_BUFFER *RetBuffer) 678114237Snjl{ 679114237Snjl ACPI_OPERAND_OBJECT *ObjDesc; 680114237Snjl ACPI_STATUS Status; 681114237Snjl 682114237Snjl 683167802Sjkim ACPI_FUNCTION_TRACE (RsGetMethodData); 684114237Snjl 685114237Snjl 686114237Snjl /* Parameters guaranteed valid by caller */ 687114237Snjl 688151937Sjkim /* Execute the method, no parameters */ 689151937Sjkim 690114237Snjl Status = AcpiUtEvaluateObject (Handle, Path, ACPI_BTYPE_BUFFER, &ObjDesc); 691167802Sjkim if (ACPI_FAILURE (Status)) 692167802Sjkim { 693114237Snjl return_ACPI_STATUS (Status); 69467754Smsmith } 69567754Smsmith 69667754Smsmith /* 69767754Smsmith * Make the call to create a resource linked list from the 698114237Snjl * byte stream buffer that comes back from the method 69991116Smsmith * execution. 70067754Smsmith */ 70199679Siwasaki Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); 70267754Smsmith 703114237Snjl /* On exit, we must delete the object returned by EvaluateObject */ 70467754Smsmith 70599679Siwasaki AcpiUtRemoveReference (ObjDesc); 70667754Smsmith return_ACPI_STATUS (Status); 70767754Smsmith} 70867754Smsmith 709167802Sjkim 71067754Smsmith/******************************************************************************* 71167754Smsmith * 71267754Smsmith * FUNCTION: AcpiRsSetSrsMethodData 71367754Smsmith * 714167802Sjkim * PARAMETERS: Node - Device node 715167802Sjkim * InBuffer - Pointer to a buffer structure of the 716167802Sjkim * parameter 71767754Smsmith * 71877424Smsmith * RETURN: Status 71967754Smsmith * 72067754Smsmith * DESCRIPTION: This function is called to set the _SRS of an object contained 72167754Smsmith * in an object specified by the handle passed in 72267754Smsmith * 72367754Smsmith * If the function fails an appropriate status will be returned 72467754Smsmith * and the contents of the callers buffer is undefined. 72567754Smsmith * 726167802Sjkim * Note: Parameters guaranteed valid by caller 727167802Sjkim * 72867754Smsmith ******************************************************************************/ 72967754Smsmith 73067754SmsmithACPI_STATUS 73167754SmsmithAcpiRsSetSrsMethodData ( 732167802Sjkim ACPI_NAMESPACE_NODE *Node, 73367754Smsmith ACPI_BUFFER *InBuffer) 73467754Smsmith{ 735167802Sjkim ACPI_EVALUATE_INFO *Info; 736167802Sjkim ACPI_OPERAND_OBJECT *Args[2]; 73767754Smsmith ACPI_STATUS Status; 73891116Smsmith ACPI_BUFFER Buffer; 73967754Smsmith 74067754Smsmith 741167802Sjkim ACPI_FUNCTION_TRACE (RsSetSrsMethodData); 74267754Smsmith 74367754Smsmith 744167802Sjkim /* Allocate and initialize the evaluation information block */ 74567754Smsmith 746167802Sjkim Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); 747167802Sjkim if (!Info) 748167802Sjkim { 749167802Sjkim return_ACPI_STATUS (AE_NO_MEMORY); 750167802Sjkim } 751167802Sjkim 752167802Sjkim Info->PrefixNode = Node; 753167802Sjkim Info->Pathname = METHOD_NAME__SRS; 754167802Sjkim Info->Parameters = Args; 755167802Sjkim Info->Flags = ACPI_IGNORE_RETURN_VALUE; 756167802Sjkim 75767754Smsmith /* 75867754Smsmith * The InBuffer parameter will point to a linked list of 759167802Sjkim * resource parameters. It needs to be formatted into a 76091116Smsmith * byte stream to be sent in as an input parameter to _SRS 76191116Smsmith * 76291116Smsmith * Convert the linked list into a byte stream 76367754Smsmith */ 76491116Smsmith Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 765151937Sjkim Status = AcpiRsCreateAmlResources (InBuffer->Pointer, &Buffer); 76691116Smsmith if (ACPI_FAILURE (Status)) 76767754Smsmith { 768167802Sjkim goto Cleanup; 76967754Smsmith } 77067754Smsmith 771167802Sjkim /* Create and initialize the method parameter object */ 772151937Sjkim 773167802Sjkim Args[0] = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); 774167802Sjkim if (!Args[0]) 77584491Smsmith { 776167802Sjkim /* 777167802Sjkim * Must free the buffer allocated above (otherwise it is freed 778167802Sjkim * later) 779167802Sjkim */ 780167802Sjkim ACPI_FREE (Buffer.Pointer); 781167802Sjkim Status = AE_NO_MEMORY; 782167802Sjkim goto Cleanup; 78384491Smsmith } 78467754Smsmith 785167802Sjkim Args[0]->Buffer.Length = (UINT32) Buffer.Length; 786167802Sjkim Args[0]->Buffer.Pointer = Buffer.Pointer; 787167802Sjkim Args[0]->Common.Flags = AOPOBJ_DATA_VALID; 788167802Sjkim Args[1] = NULL; 789151937Sjkim 790167802Sjkim /* Execute the method, no return value is expected */ 79167754Smsmith 792167802Sjkim Status = AcpiNsEvaluate (Info); 793129684Snjl 794167802Sjkim /* Clean up and return the status from AcpiNsEvaluate */ 79567754Smsmith 796167802Sjkim AcpiUtRemoveReference (Args[0]); 797151937Sjkim 798167802SjkimCleanup: 799167802Sjkim ACPI_FREE (Info); 80067754Smsmith return_ACPI_STATUS (Status); 80167754Smsmith} 80267754Smsmith 803