minor fixes for safecopy & safemap tests
[minix.git] / drivers / acpi / resources / rsutils.c
blobb5c2ab5a7334d7c1316fb3d14e8007f0cfa44dee
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 - 2010, 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 *****************************************************************************/
117 #define __RSUTILS_C__
119 #include "acpi.h"
120 #include "accommon.h"
121 #include "acnamesp.h"
122 #include "acresrc.h"
125 #define _COMPONENT ACPI_RESOURCES
126 ACPI_MODULE_NAME ("rsutils")
129 /*******************************************************************************
131 * FUNCTION: AcpiRsDecodeBitmask
133 * PARAMETERS: Mask - Bitmask to decode
134 * List - Where the converted list is returned
136 * RETURN: Count of bits set (length of list)
138 * DESCRIPTION: Convert a bit mask into a list of values
140 ******************************************************************************/
142 UINT8
143 AcpiRsDecodeBitmask (
144 UINT16 Mask,
145 UINT8 *List)
147 UINT8 i;
148 UINT8 BitCount;
151 ACPI_FUNCTION_ENTRY ();
154 /* Decode the mask bits */
156 for (i = 0, BitCount = 0; Mask; i++)
158 if (Mask & 0x0001)
160 List[BitCount] = i;
161 BitCount++;
164 Mask >>= 1;
167 return (BitCount);
171 /*******************************************************************************
173 * FUNCTION: AcpiRsEncodeBitmask
175 * PARAMETERS: List - List of values to encode
176 * Count - Length of list
178 * RETURN: Encoded bitmask
180 * DESCRIPTION: Convert a list of values to an encoded bitmask
182 ******************************************************************************/
184 UINT16
185 AcpiRsEncodeBitmask (
186 UINT8 *List,
187 UINT8 Count)
189 UINT32 i;
190 UINT16 Mask;
193 ACPI_FUNCTION_ENTRY ();
196 /* Encode the list into a single bitmask */
198 for (i = 0, Mask = 0; i < Count; i++)
200 Mask |= (0x1 << List[i]);
203 return (Mask);
207 /*******************************************************************************
209 * FUNCTION: AcpiRsMoveData
211 * PARAMETERS: Destination - Pointer to the destination descriptor
212 * Source - Pointer to the source descriptor
213 * ItemCount - How many items to move
214 * MoveType - Byte width
216 * RETURN: None
218 * DESCRIPTION: Move multiple data items from one descriptor to another. Handles
219 * alignment issues and endian issues if necessary, as configured
220 * via the ACPI_MOVE_* macros. (This is why a memcpy is not used)
222 ******************************************************************************/
224 void
225 AcpiRsMoveData (
226 void *Destination,
227 void *Source,
228 UINT16 ItemCount,
229 UINT8 MoveType)
231 UINT32 i;
234 ACPI_FUNCTION_ENTRY ();
237 /* One move per item */
239 for (i = 0; i < ItemCount; i++)
241 switch (MoveType)
244 * For the 8-bit case, we can perform the move all at once
245 * since there are no alignment or endian issues
247 case ACPI_RSC_MOVE8:
248 ACPI_MEMCPY (Destination, Source, ItemCount);
249 return;
252 * 16-, 32-, and 64-bit cases must use the move macros that perform
253 * endian conversion and/or accomodate hardware that cannot perform
254 * misaligned memory transfers
256 case ACPI_RSC_MOVE16:
257 ACPI_MOVE_16_TO_16 (&ACPI_CAST_PTR (UINT16, Destination)[i],
258 &ACPI_CAST_PTR (UINT16, Source)[i]);
259 break;
261 case ACPI_RSC_MOVE32:
262 ACPI_MOVE_32_TO_32 (&ACPI_CAST_PTR (UINT32, Destination)[i],
263 &ACPI_CAST_PTR (UINT32, Source)[i]);
264 break;
266 case ACPI_RSC_MOVE64:
267 ACPI_MOVE_64_TO_64 (&ACPI_CAST_PTR (UINT64, Destination)[i],
268 &ACPI_CAST_PTR (UINT64, Source)[i]);
269 break;
271 default:
272 return;
278 /*******************************************************************************
280 * FUNCTION: AcpiRsSetResourceLength
282 * PARAMETERS: TotalLength - Length of the AML descriptor, including
283 * the header and length fields.
284 * Aml - Pointer to the raw AML descriptor
286 * RETURN: None
288 * DESCRIPTION: Set the ResourceLength field of an AML
289 * resource descriptor, both Large and Small descriptors are
290 * supported automatically. Note: Descriptor Type field must
291 * be valid.
293 ******************************************************************************/
295 void
296 AcpiRsSetResourceLength (
297 ACPI_RSDESC_SIZE TotalLength,
298 AML_RESOURCE *Aml)
300 ACPI_RS_LENGTH ResourceLength;
303 ACPI_FUNCTION_ENTRY ();
306 /* Length is the total descriptor length minus the header length */
308 ResourceLength = (ACPI_RS_LENGTH)
309 (TotalLength - AcpiUtGetResourceHeaderLength (Aml));
311 /* Length is stored differently for large and small descriptors */
313 if (Aml->SmallHeader.DescriptorType & ACPI_RESOURCE_NAME_LARGE)
315 /* Large descriptor -- bytes 1-2 contain the 16-bit length */
317 ACPI_MOVE_16_TO_16 (&Aml->LargeHeader.ResourceLength, &ResourceLength);
319 else
321 /* Small descriptor -- bits 2:0 of byte 0 contain the length */
323 Aml->SmallHeader.DescriptorType = (UINT8)
325 /* Clear any existing length, preserving descriptor type bits */
327 ((Aml->SmallHeader.DescriptorType & ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK)
329 | ResourceLength);
334 /*******************************************************************************
336 * FUNCTION: AcpiRsSetResourceHeader
338 * PARAMETERS: DescriptorType - Byte to be inserted as the type
339 * TotalLength - Length of the AML descriptor, including
340 * the header and length fields.
341 * Aml - Pointer to the raw AML descriptor
343 * RETURN: None
345 * DESCRIPTION: Set the DescriptorType and ResourceLength fields of an AML
346 * resource descriptor, both Large and Small descriptors are
347 * supported automatically
349 ******************************************************************************/
351 void
352 AcpiRsSetResourceHeader (
353 UINT8 DescriptorType,
354 ACPI_RSDESC_SIZE TotalLength,
355 AML_RESOURCE *Aml)
357 ACPI_FUNCTION_ENTRY ();
360 /* Set the Resource Type */
362 Aml->SmallHeader.DescriptorType = DescriptorType;
364 /* Set the Resource Length */
366 AcpiRsSetResourceLength (TotalLength, Aml);
370 /*******************************************************************************
372 * FUNCTION: AcpiRsStrcpy
374 * PARAMETERS: Destination - Pointer to the destination string
375 * Source - Pointer to the source string
377 * RETURN: String length, including NULL terminator
379 * DESCRIPTION: Local string copy that returns the string length, saving a
380 * strcpy followed by a strlen.
382 ******************************************************************************/
384 static UINT16
385 AcpiRsStrcpy (
386 char *Destination,
387 char *Source)
389 UINT16 i;
392 ACPI_FUNCTION_ENTRY ();
395 for (i = 0; Source[i]; i++)
397 Destination[i] = Source[i];
400 Destination[i] = 0;
402 /* Return string length including the NULL terminator */
404 return ((UINT16) (i + 1));
408 /*******************************************************************************
410 * FUNCTION: AcpiRsGetResourceSource
412 * PARAMETERS: ResourceLength - Length field of the descriptor
413 * MinimumLength - Minimum length of the descriptor (minus
414 * any optional fields)
415 * ResourceSource - Where the ResourceSource is returned
416 * Aml - Pointer to the raw AML descriptor
417 * StringPtr - (optional) where to store the actual
418 * ResourceSource string
420 * RETURN: Length of the string plus NULL terminator, rounded up to native
421 * word boundary
423 * DESCRIPTION: Copy the optional ResourceSource data from a raw AML descriptor
424 * to an internal resource descriptor
426 ******************************************************************************/
428 ACPI_RS_LENGTH
429 AcpiRsGetResourceSource (
430 ACPI_RS_LENGTH ResourceLength,
431 ACPI_RS_LENGTH MinimumLength,
432 ACPI_RESOURCE_SOURCE *ResourceSource,
433 AML_RESOURCE *Aml,
434 char *StringPtr)
436 ACPI_RSDESC_SIZE TotalLength;
437 UINT8 *AmlResourceSource;
440 ACPI_FUNCTION_ENTRY ();
443 TotalLength = ResourceLength + sizeof (AML_RESOURCE_LARGE_HEADER);
444 AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength);
447 * ResourceSource is present if the length of the descriptor is longer than
448 * the minimum length.
450 * Note: Some resource descriptors will have an additional null, so
451 * we add 1 to the minimum length.
453 if (TotalLength > (ACPI_RSDESC_SIZE) (MinimumLength + 1))
455 /* Get the ResourceSourceIndex */
457 ResourceSource->Index = AmlResourceSource[0];
459 ResourceSource->StringPtr = StringPtr;
460 if (!StringPtr)
463 * String destination pointer is not specified; Set the String
464 * pointer to the end of the current ResourceSource structure.
466 ResourceSource->StringPtr = ACPI_ADD_PTR (char, ResourceSource,
467 sizeof (ACPI_RESOURCE_SOURCE));
471 * In order for the Resource length to be a multiple of the native
472 * word, calculate the length of the string (+1 for NULL terminator)
473 * and expand to the next word multiple.
475 * Zero the entire area of the buffer.
477 TotalLength = (UINT32) ACPI_STRLEN (
478 ACPI_CAST_PTR (char, &AmlResourceSource[1])) + 1;
479 TotalLength = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (TotalLength);
481 ACPI_MEMSET (ResourceSource->StringPtr, 0, TotalLength);
483 /* Copy the ResourceSource string to the destination */
485 ResourceSource->StringLength = AcpiRsStrcpy (ResourceSource->StringPtr,
486 ACPI_CAST_PTR (char, &AmlResourceSource[1]));
488 return ((ACPI_RS_LENGTH) TotalLength);
491 /* ResourceSource is not present */
493 ResourceSource->Index = 0;
494 ResourceSource->StringLength = 0;
495 ResourceSource->StringPtr = NULL;
496 return (0);
500 /*******************************************************************************
502 * FUNCTION: AcpiRsSetResourceSource
504 * PARAMETERS: Aml - Pointer to the raw AML descriptor
505 * MinimumLength - Minimum length of the descriptor (minus
506 * any optional fields)
507 * ResourceSource - Internal ResourceSource
510 * RETURN: Total length of the AML descriptor
512 * DESCRIPTION: Convert an optional ResourceSource from internal format to a
513 * raw AML resource descriptor
515 ******************************************************************************/
517 ACPI_RSDESC_SIZE
518 AcpiRsSetResourceSource (
519 AML_RESOURCE *Aml,
520 ACPI_RS_LENGTH MinimumLength,
521 ACPI_RESOURCE_SOURCE *ResourceSource)
523 UINT8 *AmlResourceSource;
524 ACPI_RSDESC_SIZE DescriptorLength;
527 ACPI_FUNCTION_ENTRY ();
530 DescriptorLength = MinimumLength;
532 /* Non-zero string length indicates presence of a ResourceSource */
534 if (ResourceSource->StringLength)
536 /* Point to the end of the AML descriptor */
538 AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength);
540 /* Copy the ResourceSourceIndex */
542 AmlResourceSource[0] = (UINT8) ResourceSource->Index;
544 /* Copy the ResourceSource string */
546 ACPI_STRCPY (ACPI_CAST_PTR (char, &AmlResourceSource[1]),
547 ResourceSource->StringPtr);
550 * Add the length of the string (+ 1 for null terminator) to the
551 * final descriptor length
553 DescriptorLength += ((ACPI_RSDESC_SIZE) ResourceSource->StringLength + 1);
556 /* Return the new total length of the AML descriptor */
558 return (DescriptorLength);
562 /*******************************************************************************
564 * FUNCTION: AcpiRsGetPrtMethodData
566 * PARAMETERS: Node - Device node
567 * RetBuffer - Pointer to a buffer structure for the
568 * results
570 * RETURN: Status
572 * DESCRIPTION: This function is called to get the _PRT value of an object
573 * contained in an object specified by the handle passed in
575 * If the function fails an appropriate status will be returned
576 * and the contents of the callers buffer is undefined.
578 ******************************************************************************/
580 ACPI_STATUS
581 AcpiRsGetPrtMethodData (
582 ACPI_NAMESPACE_NODE *Node,
583 ACPI_BUFFER *RetBuffer)
585 ACPI_OPERAND_OBJECT *ObjDesc;
586 ACPI_STATUS Status;
589 ACPI_FUNCTION_TRACE (RsGetPrtMethodData);
592 /* Parameters guaranteed valid by caller */
594 /* Execute the method, no parameters */
596 Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRT,
597 ACPI_BTYPE_PACKAGE, &ObjDesc);
598 if (ACPI_FAILURE (Status))
600 return_ACPI_STATUS (Status);
604 * Create a resource linked list from the byte stream buffer that comes
605 * back from the _CRS method execution.
607 Status = AcpiRsCreatePciRoutingTable (ObjDesc, RetBuffer);
609 /* On exit, we must delete the object returned by EvaluateObject */
611 AcpiUtRemoveReference (ObjDesc);
612 return_ACPI_STATUS (Status);
616 /*******************************************************************************
618 * FUNCTION: AcpiRsGetCrsMethodData
620 * PARAMETERS: Node - Device node
621 * RetBuffer - Pointer to a buffer structure for the
622 * results
624 * RETURN: Status
626 * DESCRIPTION: This function is called to get the _CRS value of an object
627 * contained in an object specified by the handle passed in
629 * If the function fails an appropriate status will be returned
630 * and the contents of the callers buffer is undefined.
632 ******************************************************************************/
634 ACPI_STATUS
635 AcpiRsGetCrsMethodData (
636 ACPI_NAMESPACE_NODE *Node,
637 ACPI_BUFFER *RetBuffer)
639 ACPI_OPERAND_OBJECT *ObjDesc;
640 ACPI_STATUS Status;
643 ACPI_FUNCTION_TRACE (RsGetCrsMethodData);
646 /* Parameters guaranteed valid by caller */
648 /* Execute the method, no parameters */
650 Status = AcpiUtEvaluateObject (Node, METHOD_NAME__CRS,
651 ACPI_BTYPE_BUFFER, &ObjDesc);
652 if (ACPI_FAILURE (Status))
654 return_ACPI_STATUS (Status);
658 * Make the call to create a resource linked list from the
659 * byte stream buffer that comes back from the _CRS method
660 * execution.
662 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
664 /* On exit, we must delete the object returned by evaluateObject */
666 AcpiUtRemoveReference (ObjDesc);
667 return_ACPI_STATUS (Status);
671 /*******************************************************************************
673 * FUNCTION: AcpiRsGetPrsMethodData
675 * PARAMETERS: Node - Device node
676 * RetBuffer - Pointer to a buffer structure for the
677 * results
679 * RETURN: Status
681 * DESCRIPTION: This function is called to get the _PRS value of an object
682 * contained in an object specified by the handle passed in
684 * If the function fails an appropriate status will be returned
685 * and the contents of the callers buffer is undefined.
687 ******************************************************************************/
689 ACPI_STATUS
690 AcpiRsGetPrsMethodData (
691 ACPI_NAMESPACE_NODE *Node,
692 ACPI_BUFFER *RetBuffer)
694 ACPI_OPERAND_OBJECT *ObjDesc;
695 ACPI_STATUS Status;
698 ACPI_FUNCTION_TRACE (RsGetPrsMethodData);
701 /* Parameters guaranteed valid by caller */
703 /* Execute the method, no parameters */
705 Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRS,
706 ACPI_BTYPE_BUFFER, &ObjDesc);
707 if (ACPI_FAILURE (Status))
709 return_ACPI_STATUS (Status);
713 * Make the call to create a resource linked list from the
714 * byte stream buffer that comes back from the _CRS method
715 * execution.
717 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
719 /* On exit, we must delete the object returned by evaluateObject */
721 AcpiUtRemoveReference (ObjDesc);
722 return_ACPI_STATUS (Status);
726 /*******************************************************************************
728 * FUNCTION: AcpiRsGetMethodData
730 * PARAMETERS: Handle - Handle to the containing object
731 * Path - Path to method, relative to Handle
732 * RetBuffer - Pointer to a buffer structure for the
733 * results
735 * RETURN: Status
737 * DESCRIPTION: This function is called to get the _CRS or _PRS value of an
738 * object contained in an object specified by the handle passed in
740 * If the function fails an appropriate status will be returned
741 * and the contents of the callers buffer is undefined.
743 ******************************************************************************/
745 ACPI_STATUS
746 AcpiRsGetMethodData (
747 ACPI_HANDLE Handle,
748 char *Path,
749 ACPI_BUFFER *RetBuffer)
751 ACPI_OPERAND_OBJECT *ObjDesc;
752 ACPI_STATUS Status;
755 ACPI_FUNCTION_TRACE (RsGetMethodData);
758 /* Parameters guaranteed valid by caller */
760 /* Execute the method, no parameters */
762 Status = AcpiUtEvaluateObject (Handle, Path, ACPI_BTYPE_BUFFER, &ObjDesc);
763 if (ACPI_FAILURE (Status))
765 return_ACPI_STATUS (Status);
769 * Make the call to create a resource linked list from the
770 * byte stream buffer that comes back from the method
771 * execution.
773 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
775 /* On exit, we must delete the object returned by EvaluateObject */
777 AcpiUtRemoveReference (ObjDesc);
778 return_ACPI_STATUS (Status);
782 /*******************************************************************************
784 * FUNCTION: AcpiRsSetSrsMethodData
786 * PARAMETERS: Node - Device node
787 * InBuffer - Pointer to a buffer structure of the
788 * parameter
790 * RETURN: Status
792 * DESCRIPTION: This function is called to set the _SRS of an object contained
793 * in an object specified by the handle passed in
795 * If the function fails an appropriate status will be returned
796 * and the contents of the callers buffer is undefined.
798 * Note: Parameters guaranteed valid by caller
800 ******************************************************************************/
802 ACPI_STATUS
803 AcpiRsSetSrsMethodData (
804 ACPI_NAMESPACE_NODE *Node,
805 ACPI_BUFFER *InBuffer)
807 ACPI_EVALUATE_INFO *Info;
808 ACPI_OPERAND_OBJECT *Args[2];
809 ACPI_STATUS Status;
810 ACPI_BUFFER Buffer;
813 ACPI_FUNCTION_TRACE (RsSetSrsMethodData);
816 /* Allocate and initialize the evaluation information block */
818 Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
819 if (!Info)
821 return_ACPI_STATUS (AE_NO_MEMORY);
824 Info->PrefixNode = Node;
825 Info->Pathname = METHOD_NAME__SRS;
826 Info->Parameters = Args;
827 Info->Flags = ACPI_IGNORE_RETURN_VALUE;
830 * The InBuffer parameter will point to a linked list of
831 * resource parameters. It needs to be formatted into a
832 * byte stream to be sent in as an input parameter to _SRS
834 * Convert the linked list into a byte stream
836 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
837 Status = AcpiRsCreateAmlResources (InBuffer->Pointer, &Buffer);
838 if (ACPI_FAILURE (Status))
840 goto Cleanup;
843 /* Create and initialize the method parameter object */
845 Args[0] = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);
846 if (!Args[0])
849 * Must free the buffer allocated above (otherwise it is freed
850 * later)
852 ACPI_FREE (Buffer.Pointer);
853 Status = AE_NO_MEMORY;
854 goto Cleanup;
857 Args[0]->Buffer.Length = (UINT32) Buffer.Length;
858 Args[0]->Buffer.Pointer = Buffer.Pointer;
859 Args[0]->Common.Flags = AOPOBJ_DATA_VALID;
860 Args[1] = NULL;
862 /* Execute the method, no return value is expected */
864 Status = AcpiNsEvaluate (Info);
866 /* Clean up and return the status from AcpiNsEvaluate */
868 AcpiUtRemoveReference (Args[0]);
870 Cleanup:
871 ACPI_FREE (Info);
872 return_ACPI_STATUS (Status);