Sync ACPICA with Intel's version 20180508 (from previously 20170831).
[dragonfly.git] / sys / contrib / dev / acpica / source / components / resources / rsutils.c
bloba0dd1517e1f0fd33d5881366088a086d975a71ef
1 /*******************************************************************************
3 * Module Name: rsutils - Utilities for the resource manager
5 ******************************************************************************/
7 /******************************************************************************
9 * 1. Copyright Notice
11 * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp.
12 * All rights reserved.
14 * 2. License
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
19 * property rights.
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
37 * The above copyright and patent license is granted only if the following
38 * conditions are met:
40 * 3. Conditions
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
64 * make.
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
70 * distribution.
72 * 3.4. Intel retains all right, title, and interest in and to the Original
73 * Intel Code.
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
80 * 4. Disclaimer and Export Compliance
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88 * PARTICULAR PURPOSE.
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97 * LIMITED REMEDY.
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
114 *****************************************************************************
116 * Alternatively, you may choose to be licensed under the terms of the
117 * following license:
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
121 * are met:
122 * 1. Redistributions of source code must retain the above copyright
123 * notice, this list of conditions, and the following disclaimer,
124 * without modification.
125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 * substantially similar to the "NO WARRANTY" disclaimer below
127 * ("Disclaimer") and any redistribution must be conditioned upon
128 * including a substantially similar Disclaimer requirement for further
129 * binary redistribution.
130 * 3. Neither the names of the above-listed copyright holders nor the names
131 * of any contributors may be used to endorse or promote products derived
132 * from this software without specific prior written permission.
134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
146 * Alternatively, you may choose to be licensed under the terms of the
147 * GNU General Public License ("GPL") version 2 as published by the Free
148 * Software Foundation.
150 *****************************************************************************/
152 #include "acpi.h"
153 #include "accommon.h"
154 #include "acnamesp.h"
155 #include "acresrc.h"
158 #define _COMPONENT ACPI_RESOURCES
159 ACPI_MODULE_NAME ("rsutils")
162 /*******************************************************************************
164 * FUNCTION: AcpiRsDecodeBitmask
166 * PARAMETERS: Mask - Bitmask to decode
167 * List - Where the converted list is returned
169 * RETURN: Count of bits set (length of list)
171 * DESCRIPTION: Convert a bit mask into a list of values
173 ******************************************************************************/
175 UINT8
176 AcpiRsDecodeBitmask (
177 UINT16 Mask,
178 UINT8 *List)
180 UINT8 i;
181 UINT8 BitCount;
184 ACPI_FUNCTION_ENTRY ();
187 /* Decode the mask bits */
189 for (i = 0, BitCount = 0; Mask; i++)
191 if (Mask & 0x0001)
193 List[BitCount] = i;
194 BitCount++;
197 Mask >>= 1;
200 return (BitCount);
204 /*******************************************************************************
206 * FUNCTION: AcpiRsEncodeBitmask
208 * PARAMETERS: List - List of values to encode
209 * Count - Length of list
211 * RETURN: Encoded bitmask
213 * DESCRIPTION: Convert a list of values to an encoded bitmask
215 ******************************************************************************/
217 UINT16
218 AcpiRsEncodeBitmask (
219 UINT8 *List,
220 UINT8 Count)
222 UINT32 i;
223 UINT16 Mask;
226 ACPI_FUNCTION_ENTRY ();
229 /* Encode the list into a single bitmask */
231 for (i = 0, Mask = 0; i < Count; i++)
233 Mask |= (0x1 << List[i]);
236 return (Mask);
240 /*******************************************************************************
242 * FUNCTION: AcpiRsMoveData
244 * PARAMETERS: Destination - Pointer to the destination descriptor
245 * Source - Pointer to the source descriptor
246 * ItemCount - How many items to move
247 * MoveType - Byte width
249 * RETURN: None
251 * DESCRIPTION: Move multiple data items from one descriptor to another. Handles
252 * alignment issues and endian issues if necessary, as configured
253 * via the ACPI_MOVE_* macros. (This is why a memcpy is not used)
255 ******************************************************************************/
257 void
258 AcpiRsMoveData (
259 void *Destination,
260 void *Source,
261 UINT16 ItemCount,
262 UINT8 MoveType)
264 UINT32 i;
267 ACPI_FUNCTION_ENTRY ();
270 /* One move per item */
272 for (i = 0; i < ItemCount; i++)
274 switch (MoveType)
277 * For the 8-bit case, we can perform the move all at once
278 * since there are no alignment or endian issues
280 case ACPI_RSC_MOVE8:
281 case ACPI_RSC_MOVE_GPIO_RES:
282 case ACPI_RSC_MOVE_SERIAL_VEN:
283 case ACPI_RSC_MOVE_SERIAL_RES:
285 memcpy (Destination, Source, ItemCount);
286 return;
289 * 16-, 32-, and 64-bit cases must use the move macros that perform
290 * endian conversion and/or accommodate hardware that cannot perform
291 * misaligned memory transfers
293 case ACPI_RSC_MOVE16:
294 case ACPI_RSC_MOVE_GPIO_PIN:
296 ACPI_MOVE_16_TO_16 (
297 &ACPI_CAST_PTR (UINT16, Destination)[i],
298 &ACPI_CAST_PTR (UINT16, Source)[i]);
299 break;
301 case ACPI_RSC_MOVE32:
303 ACPI_MOVE_32_TO_32 (
304 &ACPI_CAST_PTR (UINT32, Destination)[i],
305 &ACPI_CAST_PTR (UINT32, Source)[i]);
306 break;
308 case ACPI_RSC_MOVE64:
310 ACPI_MOVE_64_TO_64 (
311 &ACPI_CAST_PTR (UINT64, Destination)[i],
312 &ACPI_CAST_PTR (UINT64, Source)[i]);
313 break;
315 default:
317 return;
323 /*******************************************************************************
325 * FUNCTION: AcpiRsSetResourceLength
327 * PARAMETERS: TotalLength - Length of the AML descriptor, including
328 * the header and length fields.
329 * Aml - Pointer to the raw AML descriptor
331 * RETURN: None
333 * DESCRIPTION: Set the ResourceLength field of an AML
334 * resource descriptor, both Large and Small descriptors are
335 * supported automatically. Note: Descriptor Type field must
336 * be valid.
338 ******************************************************************************/
340 void
341 AcpiRsSetResourceLength (
342 ACPI_RSDESC_SIZE TotalLength,
343 AML_RESOURCE *Aml)
345 ACPI_RS_LENGTH ResourceLength;
348 ACPI_FUNCTION_ENTRY ();
351 /* Length is the total descriptor length minus the header length */
353 ResourceLength = (ACPI_RS_LENGTH)
354 (TotalLength - AcpiUtGetResourceHeaderLength (Aml));
356 /* Length is stored differently for large and small descriptors */
358 if (Aml->SmallHeader.DescriptorType & ACPI_RESOURCE_NAME_LARGE)
360 /* Large descriptor -- bytes 1-2 contain the 16-bit length */
362 ACPI_MOVE_16_TO_16 (
363 &Aml->LargeHeader.ResourceLength, &ResourceLength);
365 else
368 * Small descriptor -- bits 2:0 of byte 0 contain the length
369 * Clear any existing length, preserving descriptor type bits
371 Aml->SmallHeader.DescriptorType = (UINT8)
372 ((Aml->SmallHeader.DescriptorType &
373 ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK)
374 | ResourceLength);
379 /*******************************************************************************
381 * FUNCTION: AcpiRsSetResourceHeader
383 * PARAMETERS: DescriptorType - Byte to be inserted as the type
384 * TotalLength - Length of the AML descriptor, including
385 * the header and length fields.
386 * Aml - Pointer to the raw AML descriptor
388 * RETURN: None
390 * DESCRIPTION: Set the DescriptorType and ResourceLength fields of an AML
391 * resource descriptor, both Large and Small descriptors are
392 * supported automatically
394 ******************************************************************************/
396 void
397 AcpiRsSetResourceHeader (
398 UINT8 DescriptorType,
399 ACPI_RSDESC_SIZE TotalLength,
400 AML_RESOURCE *Aml)
402 ACPI_FUNCTION_ENTRY ();
405 /* Set the Resource Type */
407 Aml->SmallHeader.DescriptorType = DescriptorType;
409 /* Set the Resource Length */
411 AcpiRsSetResourceLength (TotalLength, Aml);
415 /*******************************************************************************
417 * FUNCTION: AcpiRsStrcpy
419 * PARAMETERS: Destination - Pointer to the destination string
420 * Source - Pointer to the source string
422 * RETURN: String length, including NULL terminator
424 * DESCRIPTION: Local string copy that returns the string length, saving a
425 * strcpy followed by a strlen.
427 ******************************************************************************/
429 static UINT16
430 AcpiRsStrcpy (
431 char *Destination,
432 char *Source)
434 UINT16 i;
437 ACPI_FUNCTION_ENTRY ();
440 for (i = 0; Source[i]; i++)
442 Destination[i] = Source[i];
445 Destination[i] = 0;
447 /* Return string length including the NULL terminator */
449 return ((UINT16) (i + 1));
453 /*******************************************************************************
455 * FUNCTION: AcpiRsGetResourceSource
457 * PARAMETERS: ResourceLength - Length field of the descriptor
458 * MinimumLength - Minimum length of the descriptor (minus
459 * any optional fields)
460 * ResourceSource - Where the ResourceSource is returned
461 * Aml - Pointer to the raw AML descriptor
462 * StringPtr - (optional) where to store the actual
463 * ResourceSource string
465 * RETURN: Length of the string plus NULL terminator, rounded up to native
466 * word boundary
468 * DESCRIPTION: Copy the optional ResourceSource data from a raw AML descriptor
469 * to an internal resource descriptor
471 ******************************************************************************/
473 ACPI_RS_LENGTH
474 AcpiRsGetResourceSource (
475 ACPI_RS_LENGTH ResourceLength,
476 ACPI_RS_LENGTH MinimumLength,
477 ACPI_RESOURCE_SOURCE *ResourceSource,
478 AML_RESOURCE *Aml,
479 char *StringPtr)
481 ACPI_RSDESC_SIZE TotalLength;
482 UINT8 *AmlResourceSource;
485 ACPI_FUNCTION_ENTRY ();
488 TotalLength = ResourceLength + sizeof (AML_RESOURCE_LARGE_HEADER);
489 AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength);
492 * ResourceSource is present if the length of the descriptor is longer
493 * than the minimum length.
495 * Note: Some resource descriptors will have an additional null, so
496 * we add 1 to the minimum length.
498 if (TotalLength > (ACPI_RSDESC_SIZE) (MinimumLength + 1))
500 /* Get the ResourceSourceIndex */
502 ResourceSource->Index = AmlResourceSource[0];
504 ResourceSource->StringPtr = StringPtr;
505 if (!StringPtr)
508 * String destination pointer is not specified; Set the String
509 * pointer to the end of the current ResourceSource structure.
511 ResourceSource->StringPtr = ACPI_ADD_PTR (
512 char, ResourceSource, sizeof (ACPI_RESOURCE_SOURCE));
516 * In order for the Resource length to be a multiple of the native
517 * word, calculate the length of the string (+1 for NULL terminator)
518 * and expand to the next word multiple.
520 * Zero the entire area of the buffer.
522 TotalLength = (UINT32) strlen (
523 ACPI_CAST_PTR (char, &AmlResourceSource[1])) + 1;
525 TotalLength = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (TotalLength);
527 memset (ResourceSource->StringPtr, 0, TotalLength);
529 /* Copy the ResourceSource string to the destination */
531 ResourceSource->StringLength = AcpiRsStrcpy (
532 ResourceSource->StringPtr,
533 ACPI_CAST_PTR (char, &AmlResourceSource[1]));
535 return ((ACPI_RS_LENGTH) TotalLength);
538 /* ResourceSource is not present */
540 ResourceSource->Index = 0;
541 ResourceSource->StringLength = 0;
542 ResourceSource->StringPtr = NULL;
543 return (0);
547 /*******************************************************************************
549 * FUNCTION: AcpiRsSetResourceSource
551 * PARAMETERS: Aml - Pointer to the raw AML descriptor
552 * MinimumLength - Minimum length of the descriptor (minus
553 * any optional fields)
554 * ResourceSource - Internal ResourceSource
557 * RETURN: Total length of the AML descriptor
559 * DESCRIPTION: Convert an optional ResourceSource from internal format to a
560 * raw AML resource descriptor
562 ******************************************************************************/
564 ACPI_RSDESC_SIZE
565 AcpiRsSetResourceSource (
566 AML_RESOURCE *Aml,
567 ACPI_RS_LENGTH MinimumLength,
568 ACPI_RESOURCE_SOURCE *ResourceSource)
570 UINT8 *AmlResourceSource;
571 ACPI_RSDESC_SIZE DescriptorLength;
574 ACPI_FUNCTION_ENTRY ();
577 DescriptorLength = MinimumLength;
579 /* Non-zero string length indicates presence of a ResourceSource */
581 if (ResourceSource->StringLength)
583 /* Point to the end of the AML descriptor */
585 AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength);
587 /* Copy the ResourceSourceIndex */
589 AmlResourceSource[0] = (UINT8) ResourceSource->Index;
591 /* Copy the ResourceSource string */
593 strcpy (ACPI_CAST_PTR (char, &AmlResourceSource[1]),
594 ResourceSource->StringPtr);
597 * Add the length of the string (+ 1 for null terminator) to the
598 * final descriptor length
600 DescriptorLength += ((ACPI_RSDESC_SIZE)
601 ResourceSource->StringLength + 1);
604 /* Return the new total length of the AML descriptor */
606 return (DescriptorLength);
610 /*******************************************************************************
612 * FUNCTION: AcpiRsGetPrtMethodData
614 * PARAMETERS: Node - Device node
615 * RetBuffer - Pointer to a buffer structure for the
616 * results
618 * RETURN: Status
620 * DESCRIPTION: This function is called to get the _PRT value of an object
621 * contained in an object specified by the handle passed in
623 * If the function fails an appropriate status will be returned
624 * and the contents of the callers buffer is undefined.
626 ******************************************************************************/
628 ACPI_STATUS
629 AcpiRsGetPrtMethodData (
630 ACPI_NAMESPACE_NODE *Node,
631 ACPI_BUFFER *RetBuffer)
633 ACPI_OPERAND_OBJECT *ObjDesc;
634 ACPI_STATUS Status;
637 ACPI_FUNCTION_TRACE (RsGetPrtMethodData);
640 /* Parameters guaranteed valid by caller */
642 /* Execute the method, no parameters */
644 Status = AcpiUtEvaluateObject (
645 Node, METHOD_NAME__PRT, ACPI_BTYPE_PACKAGE, &ObjDesc);
646 if (ACPI_FAILURE (Status))
648 return_ACPI_STATUS (Status);
652 * Create a resource linked list from the byte stream buffer that comes
653 * back from the _CRS method execution.
655 Status = AcpiRsCreatePciRoutingTable (ObjDesc, RetBuffer);
657 /* On exit, we must delete the object returned by EvaluateObject */
659 AcpiUtRemoveReference (ObjDesc);
660 return_ACPI_STATUS (Status);
664 /*******************************************************************************
666 * FUNCTION: AcpiRsGetCrsMethodData
668 * PARAMETERS: Node - Device node
669 * RetBuffer - Pointer to a buffer structure for the
670 * results
672 * RETURN: Status
674 * DESCRIPTION: This function is called to get the _CRS value of an object
675 * contained in an object specified by the handle passed in
677 * If the function fails an appropriate status will be returned
678 * and the contents of the callers buffer is undefined.
680 ******************************************************************************/
682 ACPI_STATUS
683 AcpiRsGetCrsMethodData (
684 ACPI_NAMESPACE_NODE *Node,
685 ACPI_BUFFER *RetBuffer)
687 ACPI_OPERAND_OBJECT *ObjDesc;
688 ACPI_STATUS Status;
691 ACPI_FUNCTION_TRACE (RsGetCrsMethodData);
694 /* Parameters guaranteed valid by caller */
696 /* Execute the method, no parameters */
698 Status = AcpiUtEvaluateObject (
699 Node, METHOD_NAME__CRS, ACPI_BTYPE_BUFFER, &ObjDesc);
700 if (ACPI_FAILURE (Status))
702 return_ACPI_STATUS (Status);
706 * Make the call to create a resource linked list from the
707 * byte stream buffer that comes back from the _CRS method
708 * execution.
710 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
712 /* On exit, we must delete the object returned by evaluateObject */
714 AcpiUtRemoveReference (ObjDesc);
715 return_ACPI_STATUS (Status);
719 /*******************************************************************************
721 * FUNCTION: AcpiRsGetPrsMethodData
723 * PARAMETERS: Node - Device node
724 * RetBuffer - Pointer to a buffer structure for the
725 * results
727 * RETURN: Status
729 * DESCRIPTION: This function is called to get the _PRS value of an object
730 * contained in an object specified by the handle passed in
732 * If the function fails an appropriate status will be returned
733 * and the contents of the callers buffer is undefined.
735 ******************************************************************************/
737 ACPI_STATUS
738 AcpiRsGetPrsMethodData (
739 ACPI_NAMESPACE_NODE *Node,
740 ACPI_BUFFER *RetBuffer)
742 ACPI_OPERAND_OBJECT *ObjDesc;
743 ACPI_STATUS Status;
746 ACPI_FUNCTION_TRACE (RsGetPrsMethodData);
749 /* Parameters guaranteed valid by caller */
751 /* Execute the method, no parameters */
753 Status = AcpiUtEvaluateObject (
754 Node, METHOD_NAME__PRS, ACPI_BTYPE_BUFFER, &ObjDesc);
755 if (ACPI_FAILURE (Status))
757 return_ACPI_STATUS (Status);
761 * Make the call to create a resource linked list from the
762 * byte stream buffer that comes back from the _CRS method
763 * execution.
765 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
767 /* On exit, we must delete the object returned by evaluateObject */
769 AcpiUtRemoveReference (ObjDesc);
770 return_ACPI_STATUS (Status);
774 /*******************************************************************************
776 * FUNCTION: AcpiRsGetAeiMethodData
778 * PARAMETERS: Node - Device node
779 * RetBuffer - Pointer to a buffer structure for the
780 * results
782 * RETURN: Status
784 * DESCRIPTION: This function is called to get the _AEI value of an object
785 * contained in an object specified by the handle passed in
787 * If the function fails an appropriate status will be returned
788 * and the contents of the callers buffer is undefined.
790 ******************************************************************************/
792 ACPI_STATUS
793 AcpiRsGetAeiMethodData (
794 ACPI_NAMESPACE_NODE *Node,
795 ACPI_BUFFER *RetBuffer)
797 ACPI_OPERAND_OBJECT *ObjDesc;
798 ACPI_STATUS Status;
801 ACPI_FUNCTION_TRACE (RsGetAeiMethodData);
804 /* Parameters guaranteed valid by caller */
806 /* Execute the method, no parameters */
808 Status = AcpiUtEvaluateObject (
809 Node, METHOD_NAME__AEI, ACPI_BTYPE_BUFFER, &ObjDesc);
810 if (ACPI_FAILURE (Status))
812 return_ACPI_STATUS (Status);
816 * Make the call to create a resource linked list from the
817 * byte stream buffer that comes back from the _CRS method
818 * execution.
820 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
822 /* On exit, we must delete the object returned by evaluateObject */
824 AcpiUtRemoveReference (ObjDesc);
825 return_ACPI_STATUS (Status);
829 /*******************************************************************************
831 * FUNCTION: AcpiRsGetMethodData
833 * PARAMETERS: Handle - Handle to the containing object
834 * Path - Path to method, relative to Handle
835 * RetBuffer - Pointer to a buffer structure for the
836 * results
838 * RETURN: Status
840 * DESCRIPTION: This function is called to get the _CRS or _PRS value of an
841 * object contained in an object specified by the handle passed in
843 * If the function fails an appropriate status will be returned
844 * and the contents of the callers buffer is undefined.
846 ******************************************************************************/
848 ACPI_STATUS
849 AcpiRsGetMethodData (
850 ACPI_HANDLE Handle,
851 const char *Path,
852 ACPI_BUFFER *RetBuffer)
854 ACPI_OPERAND_OBJECT *ObjDesc;
855 ACPI_STATUS Status;
858 ACPI_FUNCTION_TRACE (RsGetMethodData);
861 /* Parameters guaranteed valid by caller */
863 /* Execute the method, no parameters */
865 Status = AcpiUtEvaluateObject (
866 ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Handle),
867 Path, ACPI_BTYPE_BUFFER, &ObjDesc);
868 if (ACPI_FAILURE (Status))
870 return_ACPI_STATUS (Status);
874 * Make the call to create a resource linked list from the
875 * byte stream buffer that comes back from the method
876 * execution.
878 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
880 /* On exit, we must delete the object returned by EvaluateObject */
882 AcpiUtRemoveReference (ObjDesc);
883 return_ACPI_STATUS (Status);
887 /*******************************************************************************
889 * FUNCTION: AcpiRsSetSrsMethodData
891 * PARAMETERS: Node - Device node
892 * InBuffer - Pointer to a buffer structure of the
893 * parameter
895 * RETURN: Status
897 * DESCRIPTION: This function is called to set the _SRS of an object contained
898 * in an object specified by the handle passed in
900 * If the function fails an appropriate status will be returned
901 * and the contents of the callers buffer is undefined.
903 * Note: Parameters guaranteed valid by caller
905 ******************************************************************************/
907 ACPI_STATUS
908 AcpiRsSetSrsMethodData (
909 ACPI_NAMESPACE_NODE *Node,
910 ACPI_BUFFER *InBuffer)
912 ACPI_EVALUATE_INFO *Info;
913 ACPI_OPERAND_OBJECT *Args[2];
914 ACPI_STATUS Status;
915 ACPI_BUFFER Buffer;
918 ACPI_FUNCTION_TRACE (RsSetSrsMethodData);
921 /* Allocate and initialize the evaluation information block */
923 Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
924 if (!Info)
926 return_ACPI_STATUS (AE_NO_MEMORY);
929 Info->PrefixNode = Node;
930 Info->RelativePathname = METHOD_NAME__SRS;
931 Info->Parameters = Args;
932 Info->Flags = ACPI_IGNORE_RETURN_VALUE;
935 * The InBuffer parameter will point to a linked list of
936 * resource parameters. It needs to be formatted into a
937 * byte stream to be sent in as an input parameter to _SRS
939 * Convert the linked list into a byte stream
941 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
942 Status = AcpiRsCreateAmlResources (InBuffer, &Buffer);
943 if (ACPI_FAILURE (Status))
945 goto Cleanup;
948 /* Create and initialize the method parameter object */
950 Args[0] = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);
951 if (!Args[0])
954 * Must free the buffer allocated above (otherwise it is freed
955 * later)
957 ACPI_FREE (Buffer.Pointer);
958 Status = AE_NO_MEMORY;
959 goto Cleanup;
962 Args[0]->Buffer.Length = (UINT32) Buffer.Length;
963 Args[0]->Buffer.Pointer = Buffer.Pointer;
964 Args[0]->Common.Flags = AOPOBJ_DATA_VALID;
965 Args[1] = NULL;
967 /* Execute the method, no return value is expected */
969 Status = AcpiNsEvaluate (Info);
971 /* Clean up and return the status from AcpiNsEvaluate */
973 AcpiUtRemoveReference (Args[0]);
975 Cleanup:
976 ACPI_FREE (Info);
977 return_ACPI_STATUS (Status);