xref: /titanic_50/usr/src/uts/intel/io/acpica/resources/rsutils.c (revision 263f549e5da8b32c4922f586afb365b8ae388a6c)
1 /*******************************************************************************
2  *
3  * Module Name: rsutils - Utilities for the resource manager
4  *
5  ******************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2016, Intel Corp.
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions, and the following disclaimer,
16  *    without modification.
17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18  *    substantially similar to the "NO WARRANTY" disclaimer below
19  *    ("Disclaimer") and any redistribution must be conditioned upon
20  *    including a substantially similar Disclaimer requirement for further
21  *    binary redistribution.
22  * 3. Neither the names of the above-listed copyright holders nor the names
23  *    of any contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * Alternatively, this software may be distributed under the terms of the
27  * GNU General Public License ("GPL") version 2 as published by the Free
28  * Software Foundation.
29  *
30  * NO WARRANTY
31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41  * POSSIBILITY OF SUCH DAMAGES.
42  */
43 
44 #include "acpi.h"
45 #include "accommon.h"
46 #include "acnamesp.h"
47 #include "acresrc.h"
48 
49 
50 #define _COMPONENT          ACPI_RESOURCES
51         ACPI_MODULE_NAME    ("rsutils")
52 
53 
54 /*******************************************************************************
55  *
56  * FUNCTION:    AcpiRsDecodeBitmask
57  *
58  * PARAMETERS:  Mask            - Bitmask to decode
59  *              List            - Where the converted list is returned
60  *
61  * RETURN:      Count of bits set (length of list)
62  *
63  * DESCRIPTION: Convert a bit mask into a list of values
64  *
65  ******************************************************************************/
66 
67 UINT8
68 AcpiRsDecodeBitmask (
69     UINT16                  Mask,
70     UINT8                   *List)
71 {
72     UINT8                   i;
73     UINT8                   BitCount;
74 
75 
76     ACPI_FUNCTION_ENTRY ();
77 
78 
79     /* Decode the mask bits */
80 
81     for (i = 0, BitCount = 0; Mask; i++)
82     {
83         if (Mask & 0x0001)
84         {
85             List[BitCount] = i;
86             BitCount++;
87         }
88 
89         Mask >>= 1;
90     }
91 
92     return (BitCount);
93 }
94 
95 
96 /*******************************************************************************
97  *
98  * FUNCTION:    AcpiRsEncodeBitmask
99  *
100  * PARAMETERS:  List            - List of values to encode
101  *              Count           - Length of list
102  *
103  * RETURN:      Encoded bitmask
104  *
105  * DESCRIPTION: Convert a list of values to an encoded bitmask
106  *
107  ******************************************************************************/
108 
109 UINT16
110 AcpiRsEncodeBitmask (
111     UINT8                   *List,
112     UINT8                   Count)
113 {
114     UINT32                  i;
115     UINT16                  Mask;
116 
117 
118     ACPI_FUNCTION_ENTRY ();
119 
120 
121     /* Encode the list into a single bitmask */
122 
123     for (i = 0, Mask = 0; i < Count; i++)
124     {
125         Mask |= (0x1 << List[i]);
126     }
127 
128     return (Mask);
129 }
130 
131 
132 /*******************************************************************************
133  *
134  * FUNCTION:    AcpiRsMoveData
135  *
136  * PARAMETERS:  Destination         - Pointer to the destination descriptor
137  *              Source              - Pointer to the source descriptor
138  *              ItemCount           - How many items to move
139  *              MoveType            - Byte width
140  *
141  * RETURN:      None
142  *
143  * DESCRIPTION: Move multiple data items from one descriptor to another. Handles
144  *              alignment issues and endian issues if necessary, as configured
145  *              via the ACPI_MOVE_* macros. (This is why a memcpy is not used)
146  *
147  ******************************************************************************/
148 
149 void
150 AcpiRsMoveData (
151     void                    *Destination,
152     void                    *Source,
153     UINT16                  ItemCount,
154     UINT8                   MoveType)
155 {
156     UINT32                  i;
157 
158 
159     ACPI_FUNCTION_ENTRY ();
160 
161 
162     /* One move per item */
163 
164     for (i = 0; i < ItemCount; i++)
165     {
166         switch (MoveType)
167         {
168         /*
169          * For the 8-bit case, we can perform the move all at once
170          * since there are no alignment or endian issues
171          */
172         case ACPI_RSC_MOVE8:
173         case ACPI_RSC_MOVE_GPIO_RES:
174         case ACPI_RSC_MOVE_SERIAL_VEN:
175         case ACPI_RSC_MOVE_SERIAL_RES:
176 
177             memcpy (Destination, Source, ItemCount);
178             return;
179 
180         /*
181          * 16-, 32-, and 64-bit cases must use the move macros that perform
182          * endian conversion and/or accommodate hardware that cannot perform
183          * misaligned memory transfers
184          */
185         case ACPI_RSC_MOVE16:
186         case ACPI_RSC_MOVE_GPIO_PIN:
187 
188             ACPI_MOVE_16_TO_16 (
189                 &ACPI_CAST_PTR (UINT16, Destination)[i],
190                 &ACPI_CAST_PTR (UINT16, Source)[i]);
191             break;
192 
193         case ACPI_RSC_MOVE32:
194 
195             ACPI_MOVE_32_TO_32 (
196                 &ACPI_CAST_PTR (UINT32, Destination)[i],
197                 &ACPI_CAST_PTR (UINT32, Source)[i]);
198             break;
199 
200         case ACPI_RSC_MOVE64:
201 
202             ACPI_MOVE_64_TO_64 (
203                 &ACPI_CAST_PTR (UINT64, Destination)[i],
204                 &ACPI_CAST_PTR (UINT64, Source)[i]);
205             break;
206 
207         default:
208 
209             return;
210         }
211     }
212 }
213 
214 
215 /*******************************************************************************
216  *
217  * FUNCTION:    AcpiRsSetResourceLength
218  *
219  * PARAMETERS:  TotalLength         - Length of the AML descriptor, including
220  *                                    the header and length fields.
221  *              Aml                 - Pointer to the raw AML descriptor
222  *
223  * RETURN:      None
224  *
225  * DESCRIPTION: Set the ResourceLength field of an AML
226  *              resource descriptor, both Large and Small descriptors are
227  *              supported automatically. Note: Descriptor Type field must
228  *              be valid.
229  *
230  ******************************************************************************/
231 
232 void
233 AcpiRsSetResourceLength (
234     ACPI_RSDESC_SIZE        TotalLength,
235     AML_RESOURCE            *Aml)
236 {
237     ACPI_RS_LENGTH          ResourceLength;
238 
239 
240     ACPI_FUNCTION_ENTRY ();
241 
242 
243     /* Length is the total descriptor length minus the header length */
244 
245     ResourceLength = (ACPI_RS_LENGTH)
246         (TotalLength - AcpiUtGetResourceHeaderLength (Aml));
247 
248     /* Length is stored differently for large and small descriptors */
249 
250     if (Aml->SmallHeader.DescriptorType & ACPI_RESOURCE_NAME_LARGE)
251     {
252         /* Large descriptor -- bytes 1-2 contain the 16-bit length */
253 
254         ACPI_MOVE_16_TO_16 (
255             &Aml->LargeHeader.ResourceLength, &ResourceLength);
256     }
257     else
258     {
259         /*
260          * Small descriptor -- bits 2:0 of byte 0 contain the length
261          * Clear any existing length, preserving descriptor type bits
262          */
263         Aml->SmallHeader.DescriptorType = (UINT8)
264             ((Aml->SmallHeader.DescriptorType &
265                 ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK)
266             | ResourceLength);
267     }
268 }
269 
270 
271 /*******************************************************************************
272  *
273  * FUNCTION:    AcpiRsSetResourceHeader
274  *
275  * PARAMETERS:  DescriptorType      - Byte to be inserted as the type
276  *              TotalLength         - Length of the AML descriptor, including
277  *                                    the header and length fields.
278  *              Aml                 - Pointer to the raw AML descriptor
279  *
280  * RETURN:      None
281  *
282  * DESCRIPTION: Set the DescriptorType and ResourceLength fields of an AML
283  *              resource descriptor, both Large and Small descriptors are
284  *              supported automatically
285  *
286  ******************************************************************************/
287 
288 void
289 AcpiRsSetResourceHeader (
290     UINT8                   DescriptorType,
291     ACPI_RSDESC_SIZE        TotalLength,
292     AML_RESOURCE            *Aml)
293 {
294     ACPI_FUNCTION_ENTRY ();
295 
296 
297     /* Set the Resource Type */
298 
299     Aml->SmallHeader.DescriptorType = DescriptorType;
300 
301     /* Set the Resource Length */
302 
303     AcpiRsSetResourceLength (TotalLength, Aml);
304 }
305 
306 
307 /*******************************************************************************
308  *
309  * FUNCTION:    AcpiRsStrcpy
310  *
311  * PARAMETERS:  Destination         - Pointer to the destination string
312  *              Source              - Pointer to the source string
313  *
314  * RETURN:      String length, including NULL terminator
315  *
316  * DESCRIPTION: Local string copy that returns the string length, saving a
317  *              strcpy followed by a strlen.
318  *
319  ******************************************************************************/
320 
321 static UINT16
322 AcpiRsStrcpy (
323     char                    *Destination,
324     char                    *Source)
325 {
326     UINT16                  i;
327 
328 
329     ACPI_FUNCTION_ENTRY ();
330 
331 
332     for (i = 0; Source[i]; i++)
333     {
334         Destination[i] = Source[i];
335     }
336 
337     Destination[i] = 0;
338 
339     /* Return string length including the NULL terminator */
340 
341     return ((UINT16) (i + 1));
342 }
343 
344 
345 /*******************************************************************************
346  *
347  * FUNCTION:    AcpiRsGetResourceSource
348  *
349  * PARAMETERS:  ResourceLength      - Length field of the descriptor
350  *              MinimumLength       - Minimum length of the descriptor (minus
351  *                                    any optional fields)
352  *              ResourceSource      - Where the ResourceSource is returned
353  *              Aml                 - Pointer to the raw AML descriptor
354  *              StringPtr           - (optional) where to store the actual
355  *                                    ResourceSource string
356  *
357  * RETURN:      Length of the string plus NULL terminator, rounded up to native
358  *              word boundary
359  *
360  * DESCRIPTION: Copy the optional ResourceSource data from a raw AML descriptor
361  *              to an internal resource descriptor
362  *
363  ******************************************************************************/
364 
365 ACPI_RS_LENGTH
366 AcpiRsGetResourceSource (
367     ACPI_RS_LENGTH          ResourceLength,
368     ACPI_RS_LENGTH          MinimumLength,
369     ACPI_RESOURCE_SOURCE    *ResourceSource,
370     AML_RESOURCE            *Aml,
371     char                    *StringPtr)
372 {
373     ACPI_RSDESC_SIZE        TotalLength;
374     UINT8                   *AmlResourceSource;
375 
376 
377     ACPI_FUNCTION_ENTRY ();
378 
379 
380     TotalLength = ResourceLength + sizeof (AML_RESOURCE_LARGE_HEADER);
381     AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength);
382 
383     /*
384      * ResourceSource is present if the length of the descriptor is longer
385      * than the minimum length.
386      *
387      * Note: Some resource descriptors will have an additional null, so
388      * we add 1 to the minimum length.
389      */
390     if (TotalLength > (ACPI_RSDESC_SIZE) (MinimumLength + 1))
391     {
392         /* Get the ResourceSourceIndex */
393 
394         ResourceSource->Index = AmlResourceSource[0];
395 
396         ResourceSource->StringPtr = StringPtr;
397         if (!StringPtr)
398         {
399             /*
400              * String destination pointer is not specified; Set the String
401              * pointer to the end of the current ResourceSource structure.
402              */
403             ResourceSource->StringPtr = ACPI_ADD_PTR (
404                 char, ResourceSource, sizeof (ACPI_RESOURCE_SOURCE));
405         }
406 
407         /*
408          * In order for the Resource length to be a multiple of the native
409          * word, calculate the length of the string (+1 for NULL terminator)
410          * and expand to the next word multiple.
411          *
412          * Zero the entire area of the buffer.
413          */
414         TotalLength = (UINT32) strlen (
415             ACPI_CAST_PTR (char, &AmlResourceSource[1])) + 1;
416 
417         TotalLength = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (TotalLength);
418 
419         memset (ResourceSource->StringPtr, 0, TotalLength);
420 
421         /* Copy the ResourceSource string to the destination */
422 
423         ResourceSource->StringLength = AcpiRsStrcpy (
424             ResourceSource->StringPtr,
425             ACPI_CAST_PTR (char, &AmlResourceSource[1]));
426 
427         return ((ACPI_RS_LENGTH) TotalLength);
428     }
429 
430     /* ResourceSource is not present */
431 
432     ResourceSource->Index = 0;
433     ResourceSource->StringLength = 0;
434     ResourceSource->StringPtr = NULL;
435     return (0);
436 }
437 
438 
439 /*******************************************************************************
440  *
441  * FUNCTION:    AcpiRsSetResourceSource
442  *
443  * PARAMETERS:  Aml                 - Pointer to the raw AML descriptor
444  *              MinimumLength       - Minimum length of the descriptor (minus
445  *                                    any optional fields)
446  *              ResourceSource      - Internal ResourceSource
447 
448  *
449  * RETURN:      Total length of the AML descriptor
450  *
451  * DESCRIPTION: Convert an optional ResourceSource from internal format to a
452  *              raw AML resource descriptor
453  *
454  ******************************************************************************/
455 
456 ACPI_RSDESC_SIZE
457 AcpiRsSetResourceSource (
458     AML_RESOURCE            *Aml,
459     ACPI_RS_LENGTH          MinimumLength,
460     ACPI_RESOURCE_SOURCE    *ResourceSource)
461 {
462     UINT8                   *AmlResourceSource;
463     ACPI_RSDESC_SIZE        DescriptorLength;
464 
465 
466     ACPI_FUNCTION_ENTRY ();
467 
468 
469     DescriptorLength = MinimumLength;
470 
471     /* Non-zero string length indicates presence of a ResourceSource */
472 
473     if (ResourceSource->StringLength)
474     {
475         /* Point to the end of the AML descriptor */
476 
477         AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength);
478 
479         /* Copy the ResourceSourceIndex */
480 
481         AmlResourceSource[0] = (UINT8) ResourceSource->Index;
482 
483         /* Copy the ResourceSource string */
484 
485         strcpy (ACPI_CAST_PTR (char, &AmlResourceSource[1]),
486             ResourceSource->StringPtr);
487 
488         /*
489          * Add the length of the string (+ 1 for null terminator) to the
490          * final descriptor length
491          */
492         DescriptorLength += ((ACPI_RSDESC_SIZE)
493             ResourceSource->StringLength + 1);
494     }
495 
496     /* Return the new total length of the AML descriptor */
497 
498     return (DescriptorLength);
499 }
500 
501 
502 /*******************************************************************************
503  *
504  * FUNCTION:    AcpiRsGetPrtMethodData
505  *
506  * PARAMETERS:  Node            - Device node
507  *              RetBuffer       - Pointer to a buffer structure for the
508  *                                results
509  *
510  * RETURN:      Status
511  *
512  * DESCRIPTION: This function is called to get the _PRT value of an object
513  *              contained in an object specified by the handle passed in
514  *
515  *              If the function fails an appropriate status will be returned
516  *              and the contents of the callers buffer is undefined.
517  *
518  ******************************************************************************/
519 
520 ACPI_STATUS
521 AcpiRsGetPrtMethodData (
522     ACPI_NAMESPACE_NODE     *Node,
523     ACPI_BUFFER             *RetBuffer)
524 {
525     ACPI_OPERAND_OBJECT     *ObjDesc;
526     ACPI_STATUS             Status;
527 
528 
529     ACPI_FUNCTION_TRACE (RsGetPrtMethodData);
530 
531 
532     /* Parameters guaranteed valid by caller */
533 
534     /* Execute the method, no parameters */
535 
536     Status = AcpiUtEvaluateObject (
537         Node, METHOD_NAME__PRT, ACPI_BTYPE_PACKAGE, &ObjDesc);
538     if (ACPI_FAILURE (Status))
539     {
540         return_ACPI_STATUS (Status);
541     }
542 
543     /*
544      * Create a resource linked list from the byte stream buffer that comes
545      * back from the _CRS method execution.
546      */
547     Status = AcpiRsCreatePciRoutingTable (ObjDesc, RetBuffer);
548 
549     /* On exit, we must delete the object returned by EvaluateObject */
550 
551     AcpiUtRemoveReference (ObjDesc);
552     return_ACPI_STATUS (Status);
553 }
554 
555 
556 /*******************************************************************************
557  *
558  * FUNCTION:    AcpiRsGetCrsMethodData
559  *
560  * PARAMETERS:  Node            - Device node
561  *              RetBuffer       - Pointer to a buffer structure for the
562  *                                results
563  *
564  * RETURN:      Status
565  *
566  * DESCRIPTION: This function is called to get the _CRS value of an object
567  *              contained in an object specified by the handle passed in
568  *
569  *              If the function fails an appropriate status will be returned
570  *              and the contents of the callers buffer is undefined.
571  *
572  ******************************************************************************/
573 
574 ACPI_STATUS
575 AcpiRsGetCrsMethodData (
576     ACPI_NAMESPACE_NODE     *Node,
577     ACPI_BUFFER             *RetBuffer)
578 {
579     ACPI_OPERAND_OBJECT     *ObjDesc;
580     ACPI_STATUS             Status;
581 
582 
583     ACPI_FUNCTION_TRACE (RsGetCrsMethodData);
584 
585 
586     /* Parameters guaranteed valid by caller */
587 
588     /* Execute the method, no parameters */
589 
590     Status = AcpiUtEvaluateObject (
591         Node, METHOD_NAME__CRS, ACPI_BTYPE_BUFFER, &ObjDesc);
592     if (ACPI_FAILURE (Status))
593     {
594         return_ACPI_STATUS (Status);
595     }
596 
597     /*
598      * Make the call to create a resource linked list from the
599      * byte stream buffer that comes back from the _CRS method
600      * execution.
601      */
602     Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
603 
604     /* On exit, we must delete the object returned by evaluateObject */
605 
606     AcpiUtRemoveReference (ObjDesc);
607     return_ACPI_STATUS (Status);
608 }
609 
610 
611 /*******************************************************************************
612  *
613  * FUNCTION:    AcpiRsGetPrsMethodData
614  *
615  * PARAMETERS:  Node            - Device node
616  *              RetBuffer       - Pointer to a buffer structure for the
617  *                                results
618  *
619  * RETURN:      Status
620  *
621  * DESCRIPTION: This function is called to get the _PRS value of an object
622  *              contained in an object specified by the handle passed in
623  *
624  *              If the function fails an appropriate status will be returned
625  *              and the contents of the callers buffer is undefined.
626  *
627  ******************************************************************************/
628 
629 ACPI_STATUS
630 AcpiRsGetPrsMethodData (
631     ACPI_NAMESPACE_NODE     *Node,
632     ACPI_BUFFER             *RetBuffer)
633 {
634     ACPI_OPERAND_OBJECT     *ObjDesc;
635     ACPI_STATUS             Status;
636 
637 
638     ACPI_FUNCTION_TRACE (RsGetPrsMethodData);
639 
640 
641     /* Parameters guaranteed valid by caller */
642 
643     /* Execute the method, no parameters */
644 
645     Status = AcpiUtEvaluateObject (
646         Node, METHOD_NAME__PRS, ACPI_BTYPE_BUFFER, &ObjDesc);
647     if (ACPI_FAILURE (Status))
648     {
649         return_ACPI_STATUS (Status);
650     }
651 
652     /*
653      * Make the call to create a resource linked list from the
654      * byte stream buffer that comes back from the _CRS method
655      * execution.
656      */
657     Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
658 
659     /* On exit, we must delete the object returned by evaluateObject */
660 
661     AcpiUtRemoveReference (ObjDesc);
662     return_ACPI_STATUS (Status);
663 }
664 
665 
666 /*******************************************************************************
667  *
668  * FUNCTION:    AcpiRsGetAeiMethodData
669  *
670  * PARAMETERS:  Node            - Device node
671  *              RetBuffer       - Pointer to a buffer structure for the
672  *                                results
673  *
674  * RETURN:      Status
675  *
676  * DESCRIPTION: This function is called to get the _AEI value of an object
677  *              contained in an object specified by the handle passed in
678  *
679  *              If the function fails an appropriate status will be returned
680  *              and the contents of the callers buffer is undefined.
681  *
682  ******************************************************************************/
683 
684 ACPI_STATUS
685 AcpiRsGetAeiMethodData (
686     ACPI_NAMESPACE_NODE     *Node,
687     ACPI_BUFFER             *RetBuffer)
688 {
689     ACPI_OPERAND_OBJECT     *ObjDesc;
690     ACPI_STATUS             Status;
691 
692 
693     ACPI_FUNCTION_TRACE (RsGetAeiMethodData);
694 
695 
696     /* Parameters guaranteed valid by caller */
697 
698     /* Execute the method, no parameters */
699 
700     Status = AcpiUtEvaluateObject (
701         Node, METHOD_NAME__AEI, ACPI_BTYPE_BUFFER, &ObjDesc);
702     if (ACPI_FAILURE (Status))
703     {
704         return_ACPI_STATUS (Status);
705     }
706 
707     /*
708      * Make the call to create a resource linked list from the
709      * byte stream buffer that comes back from the _CRS method
710      * execution.
711      */
712     Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
713 
714     /* On exit, we must delete the object returned by evaluateObject */
715 
716     AcpiUtRemoveReference (ObjDesc);
717     return_ACPI_STATUS (Status);
718 }
719 
720 
721 /*******************************************************************************
722  *
723  * FUNCTION:    AcpiRsGetMethodData
724  *
725  * PARAMETERS:  Handle          - Handle to the containing object
726  *              Path            - Path to method, relative to Handle
727  *              RetBuffer       - Pointer to a buffer structure for the
728  *                                results
729  *
730  * RETURN:      Status
731  *
732  * DESCRIPTION: This function is called to get the _CRS or _PRS value of an
733  *              object contained in an object specified by the handle passed in
734  *
735  *              If the function fails an appropriate status will be returned
736  *              and the contents of the callers buffer is undefined.
737  *
738  ******************************************************************************/
739 
740 ACPI_STATUS
741 AcpiRsGetMethodData (
742     ACPI_HANDLE             Handle,
743     const char              *Path,
744     ACPI_BUFFER             *RetBuffer)
745 {
746     ACPI_OPERAND_OBJECT     *ObjDesc;
747     ACPI_STATUS             Status;
748 
749 
750     ACPI_FUNCTION_TRACE (RsGetMethodData);
751 
752 
753     /* Parameters guaranteed valid by caller */
754 
755     /* Execute the method, no parameters */
756 
757     Status = AcpiUtEvaluateObject (
758         ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Handle),
759         Path, ACPI_BTYPE_BUFFER, &ObjDesc);
760     if (ACPI_FAILURE (Status))
761     {
762         return_ACPI_STATUS (Status);
763     }
764 
765     /*
766      * Make the call to create a resource linked list from the
767      * byte stream buffer that comes back from the method
768      * execution.
769      */
770     Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
771 
772     /* On exit, we must delete the object returned by EvaluateObject */
773 
774     AcpiUtRemoveReference (ObjDesc);
775     return_ACPI_STATUS (Status);
776 }
777 
778 
779 /*******************************************************************************
780  *
781  * FUNCTION:    AcpiRsSetSrsMethodData
782  *
783  * PARAMETERS:  Node            - Device node
784  *              InBuffer        - Pointer to a buffer structure of the
785  *                                parameter
786  *
787  * RETURN:      Status
788  *
789  * DESCRIPTION: This function is called to set the _SRS of an object contained
790  *              in an object specified by the handle passed in
791  *
792  *              If the function fails an appropriate status will be returned
793  *              and the contents of the callers buffer is undefined.
794  *
795  * Note: Parameters guaranteed valid by caller
796  *
797  ******************************************************************************/
798 
799 ACPI_STATUS
800 AcpiRsSetSrsMethodData (
801     ACPI_NAMESPACE_NODE     *Node,
802     ACPI_BUFFER             *InBuffer)
803 {
804     ACPI_EVALUATE_INFO      *Info;
805     ACPI_OPERAND_OBJECT     *Args[2];
806     ACPI_STATUS             Status;
807     ACPI_BUFFER             Buffer;
808 
809 
810     ACPI_FUNCTION_TRACE (RsSetSrsMethodData);
811 
812 
813     /* Allocate and initialize the evaluation information block */
814 
815     Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
816     if (!Info)
817     {
818         return_ACPI_STATUS (AE_NO_MEMORY);
819     }
820 
821     Info->PrefixNode = Node;
822     Info->RelativePathname = METHOD_NAME__SRS;
823     Info->Parameters = Args;
824     Info->Flags = ACPI_IGNORE_RETURN_VALUE;
825 
826     /*
827      * The InBuffer parameter will point to a linked list of
828      * resource parameters. It needs to be formatted into a
829      * byte stream to be sent in as an input parameter to _SRS
830      *
831      * Convert the linked list into a byte stream
832      */
833     Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
834     Status = AcpiRsCreateAmlResources (InBuffer, &Buffer);
835     if (ACPI_FAILURE (Status))
836     {
837         goto Cleanup;
838     }
839 
840     /* Create and initialize the method parameter object */
841 
842     Args[0] = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);
843     if (!Args[0])
844     {
845         /*
846          * Must free the buffer allocated above (otherwise it is freed
847          * later)
848          */
849         ACPI_FREE (Buffer.Pointer);
850         Status = AE_NO_MEMORY;
851         goto Cleanup;
852     }
853 
854     Args[0]->Buffer.Length  = (UINT32) Buffer.Length;
855     Args[0]->Buffer.Pointer = Buffer.Pointer;
856     Args[0]->Common.Flags   = AOPOBJ_DATA_VALID;
857     Args[1] = NULL;
858 
859     /* Execute the method, no return value is expected */
860 
861     Status = AcpiNsEvaluate (Info);
862 
863     /* Clean up and return the status from AcpiNsEvaluate */
864 
865     AcpiUtRemoveReference (Args[0]);
866 
867 Cleanup:
868     ACPI_FREE (Info);
869     return_ACPI_STATUS (Status);
870 }
871