|
||||
Warning, cross-references for /kernel/drivers/acpica/rsutils.c need to be fixed.
0001 /******************************************************************************* 0002 * 0003 * Module Name: rsutils - Utilities for the resource manager 0004 * 0005 ******************************************************************************/ 0006 0007 /****************************************************************************** 0008 * 0009 * 1. Copyright Notice 0010 * 0011 * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. 0012 * All rights reserved. 0013 * 0014 * 2. License 0015 * 0016 * 2.1. This is your license from Intel Corp. under its intellectual property 0017 * rights. You may have additional license terms from the party that provided 0018 * you this software, covering your right to use that party's intellectual 0019 * property rights. 0020 * 0021 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 0022 * copy of the source code appearing in this file ("Covered Code") an 0023 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 0024 * base code distributed originally by Intel ("Original Intel Code") to copy, 0025 * make derivatives, distribute, use and display any portion of the Covered 0026 * Code in any form, with the right to sublicense such rights; and 0027 * 0028 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 0029 * license (with the right to sublicense), under only those claims of Intel 0030 * patents that are infringed by the Original Intel Code, to make, use, sell, 0031 * offer to sell, and import the Covered Code and derivative works thereof 0032 * solely to the minimum extent necessary to exercise the above copyright 0033 * license, and in no event shall the patent license extend to any additions 0034 * to or modifications of the Original Intel Code. No other license or right 0035 * is granted directly or by implication, estoppel or otherwise; 0036 * 0037 * The above copyright and patent license is granted only if the following 0038 * conditions are met: 0039 * 0040 * 3. Conditions 0041 * 0042 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 0043 * Redistribution of source code of any substantial portion of the Covered 0044 * Code or modification with rights to further distribute source must include 0045 * the above Copyright Notice, the above License, this list of Conditions, 0046 * and the following Disclaimer and Export Compliance provision. In addition, 0047 * Licensee must cause all Covered Code to which Licensee contributes to 0048 * contain a file documenting the changes Licensee made to create that Covered 0049 * Code and the date of any change. Licensee must include in that file the 0050 * documentation of any changes made by any predecessor Licensee. Licensee 0051 * must include a prominent statement that the modification is derived, 0052 * directly or indirectly, from Original Intel Code. 0053 * 0054 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 0055 * Redistribution of source code of any substantial portion of the Covered 0056 * Code or modification without rights to further distribute source must 0057 * include the following Disclaimer and Export Compliance provision in the 0058 * documentation and/or other materials provided with distribution. In 0059 * addition, Licensee may not authorize further sublicense of source of any 0060 * portion of the Covered Code, and must include terms to the effect that the 0061 * license from Licensee to its licensee is limited to the intellectual 0062 * property embodied in the software Licensee provides to its licensee, and 0063 * not to intellectual property embodied in modifications its licensee may 0064 * make. 0065 * 0066 * 3.3. Redistribution of Executable. Redistribution in executable form of any 0067 * substantial portion of the Covered Code or modification must reproduce the 0068 * above Copyright Notice, and the following Disclaimer and Export Compliance 0069 * provision in the documentation and/or other materials provided with the 0070 * distribution. 0071 * 0072 * 3.4. Intel retains all right, title, and interest in and to the Original 0073 * Intel Code. 0074 * 0075 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 0076 * Intel shall be used in advertising or otherwise to promote the sale, use or 0077 * other dealings in products derived from or relating to the Covered Code 0078 * without prior written authorization from Intel. 0079 * 0080 * 4. Disclaimer and Export Compliance 0081 * 0082 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 0083 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 0084 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 0085 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 0086 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 0087 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 0088 * PARTICULAR PURPOSE. 0089 * 0090 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 0091 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 0092 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 0093 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 0094 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 0095 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 0096 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 0097 * LIMITED REMEDY. 0098 * 0099 * 4.3. Licensee shall not export, either directly or indirectly, any of this 0100 * software or system incorporating such software without first obtaining any 0101 * required license or other approval from the U. S. Department of Commerce or 0102 * any other agency or department of the United States Government. In the 0103 * event Licensee exports any such software from the United States or 0104 * re-exports any such software from a foreign destination, Licensee shall 0105 * ensure that the distribution and export/re-export of the software is in 0106 * compliance with all laws, regulations, orders, or other restrictions of the 0107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 0108 * any of its subsidiaries will export/re-export any technical data, process, 0109 * software, or service, directly or indirectly, to any country for which the 0110 * United States government or any agency thereof requires an export license, 0111 * other governmental approval, or letter of assurance, without first obtaining 0112 * such license, approval or letter. 0113 * 0114 *****************************************************************************/ 0115 0116 0117 #define __RSUTILS_C__ 0118 0119 #include "acpi.h" 0120 #include "accommon.h" 0121 #include "acnamesp.h" 0122 #include "acresrc.h" 0123 0124 0125 #define _COMPONENT ACPI_RESOURCES 0126 ACPI_MODULE_NAME ("rsutils") 0127 0128 0129 /******************************************************************************* 0130 * 0131 * FUNCTION: AcpiRsDecodeBitmask 0132 * 0133 * PARAMETERS: Mask - Bitmask to decode 0134 * List - Where the converted list is returned 0135 * 0136 * RETURN: Count of bits set (length of list) 0137 * 0138 * DESCRIPTION: Convert a bit mask into a list of values 0139 * 0140 ******************************************************************************/ 0141 0142 UINT8 0143 AcpiRsDecodeBitmask ( 0144 UINT16 Mask, 0145 UINT8 *List) 0146 { 0147 UINT8 i; 0148 UINT8 BitCount; 0149 0150 0151 ACPI_FUNCTION_ENTRY (); 0152 0153 0154 /* Decode the mask bits */ 0155 0156 for (i = 0, BitCount = 0; Mask; i++) 0157 { 0158 if (Mask & 0x0001) 0159 { 0160 List[BitCount] = i; 0161 BitCount++; 0162 } 0163 0164 Mask >>= 1; 0165 } 0166 0167 return (BitCount); 0168 } 0169 0170 0171 /******************************************************************************* 0172 * 0173 * FUNCTION: AcpiRsEncodeBitmask 0174 * 0175 * PARAMETERS: List - List of values to encode 0176 * Count - Length of list 0177 * 0178 * RETURN: Encoded bitmask 0179 * 0180 * DESCRIPTION: Convert a list of values to an encoded bitmask 0181 * 0182 ******************************************************************************/ 0183 0184 UINT16 0185 AcpiRsEncodeBitmask ( 0186 UINT8 *List, 0187 UINT8 Count) 0188 { 0189 UINT32 i; 0190 UINT16 Mask; 0191 0192 0193 ACPI_FUNCTION_ENTRY (); 0194 0195 0196 /* Encode the list into a single bitmask */ 0197 0198 for (i = 0, Mask = 0; i < Count; i++) 0199 { 0200 Mask |= (0x1 << List[i]); 0201 } 0202 0203 return (Mask); 0204 } 0205 0206 0207 /******************************************************************************* 0208 * 0209 * FUNCTION: AcpiRsMoveData 0210 * 0211 * PARAMETERS: Destination - Pointer to the destination descriptor 0212 * Source - Pointer to the source descriptor 0213 * ItemCount - How many items to move 0214 * MoveType - Byte width 0215 * 0216 * RETURN: None 0217 * 0218 * DESCRIPTION: Move multiple data items from one descriptor to another. Handles 0219 * alignment issues and endian issues if necessary, as configured 0220 * via the ACPI_MOVE_* macros. (This is why a memcpy is not used) 0221 * 0222 ******************************************************************************/ 0223 0224 void 0225 AcpiRsMoveData ( 0226 void *Destination, 0227 void *Source, 0228 UINT16 ItemCount, 0229 UINT8 MoveType) 0230 { 0231 UINT32 i; 0232 0233 0234 ACPI_FUNCTION_ENTRY (); 0235 0236 0237 /* One move per item */ 0238 0239 for (i = 0; i < ItemCount; i++) 0240 { 0241 switch (MoveType) 0242 { 0243 /* 0244 * For the 8-bit case, we can perform the move all at once 0245 * since there are no alignment or endian issues 0246 */ 0247 case ACPI_RSC_MOVE8: 0248 ACPI_MEMCPY (Destination, Source, ItemCount); 0249 return; 0250 0251 /* 0252 * 16-, 32-, and 64-bit cases must use the move macros that perform 0253 * endian conversion and/or accomodate hardware that cannot perform 0254 * misaligned memory transfers 0255 */ 0256 case ACPI_RSC_MOVE16: 0257 ACPI_MOVE_16_TO_16 (&ACPI_CAST_PTR (UINT16, Destination)[i], 0258 &ACPI_CAST_PTR (UINT16, Source)[i]); 0259 break; 0260 0261 case ACPI_RSC_MOVE32: 0262 ACPI_MOVE_32_TO_32 (&ACPI_CAST_PTR (UINT32, Destination)[i], 0263 &ACPI_CAST_PTR (UINT32, Source)[i]); 0264 break; 0265 0266 case ACPI_RSC_MOVE64: 0267 ACPI_MOVE_64_TO_64 (&ACPI_CAST_PTR (UINT64, Destination)[i], 0268 &ACPI_CAST_PTR (UINT64, Source)[i]); 0269 break; 0270 0271 default: 0272 return; 0273 } 0274 } 0275 } 0276 0277 0278 /******************************************************************************* 0279 * 0280 * FUNCTION: AcpiRsSetResourceLength 0281 * 0282 * PARAMETERS: TotalLength - Length of the AML descriptor, including 0283 * the header and length fields. 0284 * Aml - Pointer to the raw AML descriptor 0285 * 0286 * RETURN: None 0287 * 0288 * DESCRIPTION: Set the ResourceLength field of an AML 0289 * resource descriptor, both Large and Small descriptors are 0290 * supported automatically. Note: Descriptor Type field must 0291 * be valid. 0292 * 0293 ******************************************************************************/ 0294 0295 void 0296 AcpiRsSetResourceLength ( 0297 ACPI_RSDESC_SIZE TotalLength, 0298 AML_RESOURCE *Aml) 0299 { 0300 ACPI_RS_LENGTH ResourceLength; 0301 0302 0303 ACPI_FUNCTION_ENTRY (); 0304 0305 0306 /* Length is the total descriptor length minus the header length */ 0307 0308 ResourceLength = (ACPI_RS_LENGTH) 0309 (TotalLength - AcpiUtGetResourceHeaderLength (Aml)); 0310 0311 /* Length is stored differently for large and small descriptors */ 0312 0313 if (Aml->SmallHeader.DescriptorType & ACPI_RESOURCE_NAME_LARGE) 0314 { 0315 /* Large descriptor -- bytes 1-2 contain the 16-bit length */ 0316 0317 ACPI_MOVE_16_TO_16 (&Aml->LargeHeader.ResourceLength, &ResourceLength); 0318 } 0319 else 0320 { 0321 /* Small descriptor -- bits 2:0 of byte 0 contain the length */ 0322 0323 Aml->SmallHeader.DescriptorType = (UINT8) 0324 0325 /* Clear any existing length, preserving descriptor type bits */ 0326 0327 ((Aml->SmallHeader.DescriptorType & ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK) 0328 0329 | ResourceLength); 0330 } 0331 } 0332 0333 0334 /******************************************************************************* 0335 * 0336 * FUNCTION: AcpiRsSetResourceHeader 0337 * 0338 * PARAMETERS: DescriptorType - Byte to be inserted as the type 0339 * TotalLength - Length of the AML descriptor, including 0340 * the header and length fields. 0341 * Aml - Pointer to the raw AML descriptor 0342 * 0343 * RETURN: None 0344 * 0345 * DESCRIPTION: Set the DescriptorType and ResourceLength fields of an AML 0346 * resource descriptor, both Large and Small descriptors are 0347 * supported automatically 0348 * 0349 ******************************************************************************/ 0350 0351 void 0352 AcpiRsSetResourceHeader ( 0353 UINT8 DescriptorType, 0354 ACPI_RSDESC_SIZE TotalLength, 0355 AML_RESOURCE *Aml) 0356 { 0357 ACPI_FUNCTION_ENTRY (); 0358 0359 0360 /* Set the Resource Type */ 0361 0362 Aml->SmallHeader.DescriptorType = DescriptorType; 0363 0364 /* Set the Resource Length */ 0365 0366 AcpiRsSetResourceLength (TotalLength, Aml); 0367 } 0368 0369 0370 /******************************************************************************* 0371 * 0372 * FUNCTION: AcpiRsStrcpy 0373 * 0374 * PARAMETERS: Destination - Pointer to the destination string 0375 * Source - Pointer to the source string 0376 * 0377 * RETURN: String length, including NULL terminator 0378 * 0379 * DESCRIPTION: Local string copy that returns the string length, saving a 0380 * strcpy followed by a strlen. 0381 * 0382 ******************************************************************************/ 0383 0384 static UINT16 0385 AcpiRsStrcpy ( 0386 char *Destination, 0387 char *Source) 0388 { 0389 UINT16 i; 0390 0391 0392 ACPI_FUNCTION_ENTRY (); 0393 0394 0395 for (i = 0; Source[i]; i++) 0396 { 0397 Destination[i] = Source[i]; 0398 } 0399 0400 Destination[i] = 0; 0401 0402 /* Return string length including the NULL terminator */ 0403 0404 return ((UINT16) (i + 1)); 0405 } 0406 0407 0408 /******************************************************************************* 0409 * 0410 * FUNCTION: AcpiRsGetResourceSource 0411 * 0412 * PARAMETERS: ResourceLength - Length field of the descriptor 0413 * MinimumLength - Minimum length of the descriptor (minus 0414 * any optional fields) 0415 * ResourceSource - Where the ResourceSource is returned 0416 * Aml - Pointer to the raw AML descriptor 0417 * StringPtr - (optional) where to store the actual 0418 * ResourceSource string 0419 * 0420 * RETURN: Length of the string plus NULL terminator, rounded up to native 0421 * word boundary 0422 * 0423 * DESCRIPTION: Copy the optional ResourceSource data from a raw AML descriptor 0424 * to an internal resource descriptor 0425 * 0426 ******************************************************************************/ 0427 0428 ACPI_RS_LENGTH 0429 AcpiRsGetResourceSource ( 0430 ACPI_RS_LENGTH ResourceLength, 0431 ACPI_RS_LENGTH MinimumLength, 0432 ACPI_RESOURCE_SOURCE *ResourceSource, 0433 AML_RESOURCE *Aml, 0434 char *StringPtr) 0435 { 0436 ACPI_RSDESC_SIZE TotalLength; 0437 UINT8 *AmlResourceSource; 0438 0439 0440 ACPI_FUNCTION_ENTRY (); 0441 0442 0443 TotalLength = ResourceLength + sizeof (AML_RESOURCE_LARGE_HEADER); 0444 AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength); 0445 0446 /* 0447 * ResourceSource is present if the length of the descriptor is longer than 0448 * the minimum length. 0449 * 0450 * Note: Some resource descriptors will have an additional null, so 0451 * we add 1 to the minimum length. 0452 */ 0453 if (TotalLength > (ACPI_RSDESC_SIZE) (MinimumLength + 1)) 0454 { 0455 /* Get the ResourceSourceIndex */ 0456 0457 ResourceSource->Index = AmlResourceSource[0]; 0458 0459 ResourceSource->StringPtr = StringPtr; 0460 if (!StringPtr) 0461 { 0462 /* 0463 * String destination pointer is not specified; Set the String 0464 * pointer to the end of the current ResourceSource structure. 0465 */ 0466 ResourceSource->StringPtr = ACPI_ADD_PTR (char, ResourceSource, 0467 sizeof (ACPI_RESOURCE_SOURCE)); 0468 } 0469 0470 /* 0471 * In order for the Resource length to be a multiple of the native 0472 * word, calculate the length of the string (+1 for NULL terminator) 0473 * and expand to the next word multiple. 0474 * 0475 * Zero the entire area of the buffer. 0476 */ 0477 TotalLength = (UINT32) ACPI_STRLEN ( 0478 ACPI_CAST_PTR (char, &AmlResourceSource[1])) + 1; 0479 TotalLength = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (TotalLength); 0480 0481 ACPI_MEMSET (ResourceSource->StringPtr, 0, TotalLength); 0482 0483 /* Copy the ResourceSource string to the destination */ 0484 0485 ResourceSource->StringLength = AcpiRsStrcpy (ResourceSource->StringPtr, 0486 ACPI_CAST_PTR (char, &AmlResourceSource[1])); 0487 0488 return ((ACPI_RS_LENGTH) TotalLength); 0489 } 0490 0491 /* ResourceSource is not present */ 0492 0493 ResourceSource->Index = 0; 0494 ResourceSource->StringLength = 0; 0495 ResourceSource->StringPtr = NULL; 0496 return (0); 0497 } 0498 0499 0500 /******************************************************************************* 0501 * 0502 * FUNCTION: AcpiRsSetResourceSource 0503 * 0504 * PARAMETERS: Aml - Pointer to the raw AML descriptor 0505 * MinimumLength - Minimum length of the descriptor (minus 0506 * any optional fields) 0507 * ResourceSource - Internal ResourceSource 0508 0509 * 0510 * RETURN: Total length of the AML descriptor 0511 * 0512 * DESCRIPTION: Convert an optional ResourceSource from internal format to a 0513 * raw AML resource descriptor 0514 * 0515 ******************************************************************************/ 0516 0517 ACPI_RSDESC_SIZE 0518 AcpiRsSetResourceSource ( 0519 AML_RESOURCE *Aml, 0520 ACPI_RS_LENGTH MinimumLength, 0521 ACPI_RESOURCE_SOURCE *ResourceSource) 0522 { 0523 UINT8 *AmlResourceSource; 0524 ACPI_RSDESC_SIZE DescriptorLength; 0525 0526 0527 ACPI_FUNCTION_ENTRY (); 0528 0529 0530 DescriptorLength = MinimumLength; 0531 0532 /* Non-zero string length indicates presence of a ResourceSource */ 0533 0534 if (ResourceSource->StringLength) 0535 { 0536 /* Point to the end of the AML descriptor */ 0537 0538 AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength); 0539 0540 /* Copy the ResourceSourceIndex */ 0541 0542 AmlResourceSource[0] = (UINT8) ResourceSource->Index; 0543 0544 /* Copy the ResourceSource string */ 0545 0546 ACPI_STRCPY (ACPI_CAST_PTR (char, &AmlResourceSource[1]), 0547 ResourceSource->StringPtr); 0548 0549 /* 0550 * Add the length of the string (+ 1 for null terminator) to the 0551 * final descriptor length 0552 */ 0553 DescriptorLength += ((ACPI_RSDESC_SIZE) ResourceSource->StringLength + 1); 0554 } 0555 0556 /* Return the new total length of the AML descriptor */ 0557 0558 return (DescriptorLength); 0559 } 0560 0561 0562 /******************************************************************************* 0563 * 0564 * FUNCTION: AcpiRsGetPrtMethodData 0565 * 0566 * PARAMETERS: Node - Device node 0567 * RetBuffer - Pointer to a buffer structure for the 0568 * results 0569 * 0570 * RETURN: Status 0571 * 0572 * DESCRIPTION: This function is called to get the _PRT value of an object 0573 * contained in an object specified by the handle passed in 0574 * 0575 * If the function fails an appropriate status will be returned 0576 * and the contents of the callers buffer is undefined. 0577 * 0578 ******************************************************************************/ 0579 0580 ACPI_STATUS 0581 AcpiRsGetPrtMethodData ( 0582 ACPI_NAMESPACE_NODE *Node, 0583 ACPI_BUFFER *RetBuffer) 0584 { 0585 ACPI_OPERAND_OBJECT *ObjDesc; 0586 ACPI_STATUS Status; 0587 0588 0589 ACPI_FUNCTION_TRACE (RsGetPrtMethodData); 0590 0591 0592 /* Parameters guaranteed valid by caller */ 0593 0594 /* Execute the method, no parameters */ 0595 0596 Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRT, 0597 ACPI_BTYPE_PACKAGE, &ObjDesc); 0598 if (ACPI_FAILURE (Status)) 0599 { 0600 return_ACPI_STATUS (Status); 0601 } 0602 0603 /* 0604 * Create a resource linked list from the byte stream buffer that comes 0605 * back from the _CRS method execution. 0606 */ 0607 Status = AcpiRsCreatePciRoutingTable (ObjDesc, RetBuffer); 0608 0609 /* On exit, we must delete the object returned by EvaluateObject */ 0610 0611 AcpiUtRemoveReference (ObjDesc); 0612 return_ACPI_STATUS (Status); 0613 } 0614 0615 0616 /******************************************************************************* 0617 * 0618 * FUNCTION: AcpiRsGetCrsMethodData 0619 * 0620 * PARAMETERS: Node - Device node 0621 * RetBuffer - Pointer to a buffer structure for the 0622 * results 0623 * 0624 * RETURN: Status 0625 * 0626 * DESCRIPTION: This function is called to get the _CRS value of an object 0627 * contained in an object specified by the handle passed in 0628 * 0629 * If the function fails an appropriate status will be returned 0630 * and the contents of the callers buffer is undefined. 0631 * 0632 ******************************************************************************/ 0633 0634 ACPI_STATUS 0635 AcpiRsGetCrsMethodData ( 0636 ACPI_NAMESPACE_NODE *Node, 0637 ACPI_BUFFER *RetBuffer) 0638 { 0639 ACPI_OPERAND_OBJECT *ObjDesc; 0640 ACPI_STATUS Status; 0641 0642 0643 ACPI_FUNCTION_TRACE (RsGetCrsMethodData); 0644 0645 0646 /* Parameters guaranteed valid by caller */ 0647 0648 /* Execute the method, no parameters */ 0649 0650 Status = AcpiUtEvaluateObject (Node, METHOD_NAME__CRS, 0651 ACPI_BTYPE_BUFFER, &ObjDesc); 0652 if (ACPI_FAILURE (Status)) 0653 { 0654 return_ACPI_STATUS (Status); 0655 } 0656 0657 /* 0658 * Make the call to create a resource linked list from the 0659 * byte stream buffer that comes back from the _CRS method 0660 * execution. 0661 */ 0662 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); 0663 0664 /* On exit, we must delete the object returned by evaluateObject */ 0665 0666 AcpiUtRemoveReference (ObjDesc); 0667 return_ACPI_STATUS (Status); 0668 } 0669 0670 0671 /******************************************************************************* 0672 * 0673 * FUNCTION: AcpiRsGetPrsMethodData 0674 * 0675 * PARAMETERS: Node - Device node 0676 * RetBuffer - Pointer to a buffer structure for the 0677 * results 0678 * 0679 * RETURN: Status 0680 * 0681 * DESCRIPTION: This function is called to get the _PRS value of an object 0682 * contained in an object specified by the handle passed in 0683 * 0684 * If the function fails an appropriate status will be returned 0685 * and the contents of the callers buffer is undefined. 0686 * 0687 ******************************************************************************/ 0688 0689 ACPI_STATUS 0690 AcpiRsGetPrsMethodData ( 0691 ACPI_NAMESPACE_NODE *Node, 0692 ACPI_BUFFER *RetBuffer) 0693 { 0694 ACPI_OPERAND_OBJECT *ObjDesc; 0695 ACPI_STATUS Status; 0696 0697 0698 ACPI_FUNCTION_TRACE (RsGetPrsMethodData); 0699 0700 0701 /* Parameters guaranteed valid by caller */ 0702 0703 /* Execute the method, no parameters */ 0704 0705 Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRS, 0706 ACPI_BTYPE_BUFFER, &ObjDesc); 0707 if (ACPI_FAILURE (Status)) 0708 { 0709 return_ACPI_STATUS (Status); 0710 } 0711 0712 /* 0713 * Make the call to create a resource linked list from the 0714 * byte stream buffer that comes back from the _CRS method 0715 * execution. 0716 */ 0717 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); 0718 0719 /* On exit, we must delete the object returned by evaluateObject */ 0720 0721 AcpiUtRemoveReference (ObjDesc); 0722 return_ACPI_STATUS (Status); 0723 } 0724 0725 0726 /******************************************************************************* 0727 * 0728 * FUNCTION: AcpiRsGetMethodData 0729 * 0730 * PARAMETERS: Handle - Handle to the containing object 0731 * Path - Path to method, relative to Handle 0732 * RetBuffer - Pointer to a buffer structure for the 0733 * results 0734 * 0735 * RETURN: Status 0736 * 0737 * DESCRIPTION: This function is called to get the _CRS or _PRS value of an 0738 * object contained in an object specified by the handle passed in 0739 * 0740 * If the function fails an appropriate status will be returned 0741 * and the contents of the callers buffer is undefined. 0742 * 0743 ******************************************************************************/ 0744 0745 ACPI_STATUS 0746 AcpiRsGetMethodData ( 0747 ACPI_HANDLE Handle, 0748 char *Path, 0749 ACPI_BUFFER *RetBuffer) 0750 { 0751 ACPI_OPERAND_OBJECT *ObjDesc; 0752 ACPI_STATUS Status; 0753 0754 0755 ACPI_FUNCTION_TRACE (RsGetMethodData); 0756 0757 0758 /* Parameters guaranteed valid by caller */ 0759 0760 /* Execute the method, no parameters */ 0761 0762 Status = AcpiUtEvaluateObject (Handle, Path, ACPI_BTYPE_BUFFER, &ObjDesc); 0763 if (ACPI_FAILURE (Status)) 0764 { 0765 return_ACPI_STATUS (Status); 0766 } 0767 0768 /* 0769 * Make the call to create a resource linked list from the 0770 * byte stream buffer that comes back from the method 0771 * execution. 0772 */ 0773 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); 0774 0775 /* On exit, we must delete the object returned by EvaluateObject */ 0776 0777 AcpiUtRemoveReference (ObjDesc); 0778 return_ACPI_STATUS (Status); 0779 } 0780 0781 0782 /******************************************************************************* 0783 * 0784 * FUNCTION: AcpiRsSetSrsMethodData 0785 * 0786 * PARAMETERS: Node - Device node 0787 * InBuffer - Pointer to a buffer structure of the 0788 * parameter 0789 * 0790 * RETURN: Status 0791 * 0792 * DESCRIPTION: This function is called to set the _SRS of an object contained 0793 * in an object specified by the handle passed in 0794 * 0795 * If the function fails an appropriate status will be returned 0796 * and the contents of the callers buffer is undefined. 0797 * 0798 * Note: Parameters guaranteed valid by caller 0799 * 0800 ******************************************************************************/ 0801 0802 ACPI_STATUS 0803 AcpiRsSetSrsMethodData ( 0804 ACPI_NAMESPACE_NODE *Node, 0805 ACPI_BUFFER *InBuffer) 0806 { 0807 ACPI_EVALUATE_INFO *Info; 0808 ACPI_OPERAND_OBJECT *Args[2]; 0809 ACPI_STATUS Status; 0810 ACPI_BUFFER Buffer; 0811 0812 0813 ACPI_FUNCTION_TRACE (RsSetSrsMethodData); 0814 0815 0816 /* Allocate and initialize the evaluation information block */ 0817 0818 Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); 0819 if (!Info) 0820 { 0821 return_ACPI_STATUS (AE_NO_MEMORY); 0822 } 0823 0824 Info->PrefixNode = Node; 0825 Info->Pathname = METHOD_NAME__SRS; 0826 Info->Parameters = Args; 0827 Info->Flags = ACPI_IGNORE_RETURN_VALUE; 0828 0829 /* 0830 * The InBuffer parameter will point to a linked list of 0831 * resource parameters. It needs to be formatted into a 0832 * byte stream to be sent in as an input parameter to _SRS 0833 * 0834 * Convert the linked list into a byte stream 0835 */ 0836 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 0837 Status = AcpiRsCreateAmlResources (InBuffer->Pointer, &Buffer); 0838 if (ACPI_FAILURE (Status)) 0839 { 0840 goto Cleanup; 0841 } 0842 0843 /* Create and initialize the method parameter object */ 0844 0845 Args[0] = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); 0846 if (!Args[0]) 0847 { 0848 /* 0849 * Must free the buffer allocated above (otherwise it is freed 0850 * later) 0851 */ 0852 ACPI_FREE (Buffer.Pointer); 0853 Status = AE_NO_MEMORY; 0854 goto Cleanup; 0855 } 0856 0857 Args[0]->Buffer.Length = (UINT32) Buffer.Length; 0858 Args[0]->Buffer.Pointer = Buffer.Pointer; 0859 Args[0]->Common.Flags = AOPOBJ_DATA_VALID; 0860 Args[1] = NULL; 0861 0862 /* Execute the method, no return value is expected */ 0863 0864 Status = AcpiNsEvaluate (Info); 0865 0866 /* Clean up and return the status from AcpiNsEvaluate */ 0867 0868 AcpiUtRemoveReference (Args[0]); 0869 0870 Cleanup: 0871 ACPI_FREE (Info); 0872 return_ACPI_STATUS (Status); 0873 } 0874
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 1.2.0 LXR engine. |