Merge branch 'vendor/OPENSSL'
[dragonfly.git] / sys / contrib / dev / acpica / source / components / resources / rsutils.c
1 /*******************************************************************************
2  *
3  * Module Name: rsutils - Utilities for the resource manager
4  *
5  ******************************************************************************/
6
7 /*
8  * Copyright (C) 2000 - 2014, 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
45 #define __RSUTILS_C__
46
47 #include "acpi.h"
48 #include "accommon.h"
49 #include "acnamesp.h"
50 #include "acresrc.h"
51
52
53 #define _COMPONENT          ACPI_RESOURCES
54         ACPI_MODULE_NAME    ("rsutils")
55
56
57 /*******************************************************************************
58  *
59  * FUNCTION:    AcpiRsDecodeBitmask
60  *
61  * PARAMETERS:  Mask            - Bitmask to decode
62  *              List            - Where the converted list is returned
63  *
64  * RETURN:      Count of bits set (length of list)
65  *
66  * DESCRIPTION: Convert a bit mask into a list of values
67  *
68  ******************************************************************************/
69
70 UINT8
71 AcpiRsDecodeBitmask (
72     UINT16                  Mask,
73     UINT8                   *List)
74 {
75     UINT8                   i;
76     UINT8                   BitCount;
77
78
79     ACPI_FUNCTION_ENTRY ();
80
81
82     /* Decode the mask bits */
83
84     for (i = 0, BitCount = 0; Mask; i++)
85     {
86         if (Mask & 0x0001)
87         {
88             List[BitCount] = i;
89             BitCount++;
90         }
91
92         Mask >>= 1;
93     }
94
95     return (BitCount);
96 }
97
98
99 /*******************************************************************************
100  *
101  * FUNCTION:    AcpiRsEncodeBitmask
102  *
103  * PARAMETERS:  List            - List of values to encode
104  *              Count           - Length of list
105  *
106  * RETURN:      Encoded bitmask
107  *
108  * DESCRIPTION: Convert a list of values to an encoded bitmask
109  *
110  ******************************************************************************/
111
112 UINT16
113 AcpiRsEncodeBitmask (
114     UINT8                   *List,
115     UINT8                   Count)
116 {
117     UINT32                  i;
118     UINT16                  Mask;
119
120
121     ACPI_FUNCTION_ENTRY ();
122
123
124     /* Encode the list into a single bitmask */
125
126     for (i = 0, Mask = 0; i < Count; i++)
127     {
128         Mask |= (0x1 << List[i]);
129     }
130
131     return (Mask);
132 }
133
134
135 /*******************************************************************************
136  *
137  * FUNCTION:    AcpiRsMoveData
138  *
139  * PARAMETERS:  Destination         - Pointer to the destination descriptor
140  *              Source              - Pointer to the source descriptor
141  *              ItemCount           - How many items to move
142  *              MoveType            - Byte width
143  *
144  * RETURN:      None
145  *
146  * DESCRIPTION: Move multiple data items from one descriptor to another. Handles
147  *              alignment issues and endian issues if necessary, as configured
148  *              via the ACPI_MOVE_* macros. (This is why a memcpy is not used)
149  *
150  ******************************************************************************/
151
152 void
153 AcpiRsMoveData (
154     void                    *Destination,
155     void                    *Source,
156     UINT16                  ItemCount,
157     UINT8                   MoveType)
158 {
159     UINT32                  i;
160
161
162     ACPI_FUNCTION_ENTRY ();
163
164
165     /* One move per item */
166
167     for (i = 0; i < ItemCount; i++)
168     {
169         switch (MoveType)
170         {
171         /*
172          * For the 8-bit case, we can perform the move all at once
173          * since there are no alignment or endian issues
174          */
175         case ACPI_RSC_MOVE8:
176         case ACPI_RSC_MOVE_GPIO_RES:
177         case ACPI_RSC_MOVE_SERIAL_VEN:
178         case ACPI_RSC_MOVE_SERIAL_RES:
179
180             ACPI_MEMCPY (Destination, Source, ItemCount);
181             return;
182
183         /*
184          * 16-, 32-, and 64-bit cases must use the move macros that perform
185          * endian conversion and/or accommodate hardware that cannot perform
186          * misaligned memory transfers
187          */
188         case ACPI_RSC_MOVE16:
189         case ACPI_RSC_MOVE_GPIO_PIN:
190
191             ACPI_MOVE_16_TO_16 (&ACPI_CAST_PTR (UINT16, Destination)[i],
192                                 &ACPI_CAST_PTR (UINT16, Source)[i]);
193             break;
194
195         case ACPI_RSC_MOVE32:
196
197             ACPI_MOVE_32_TO_32 (&ACPI_CAST_PTR (UINT32, Destination)[i],
198                                 &ACPI_CAST_PTR (UINT32, Source)[i]);
199             break;
200
201         case ACPI_RSC_MOVE64:
202
203             ACPI_MOVE_64_TO_64 (&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 (&Aml->LargeHeader.ResourceLength, &ResourceLength);
255     }
256     else
257     {
258         /* Small descriptor -- bits 2:0 of byte 0 contain the length */
259
260         Aml->SmallHeader.DescriptorType = (UINT8)
261
262             /* Clear any existing length, preserving descriptor type bits */
263
264             ((Aml->SmallHeader.DescriptorType & ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK)
265
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 than
385      * 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 (char, ResourceSource,
404                 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) ACPI_STRLEN (
415             ACPI_CAST_PTR (char, &AmlResourceSource[1])) + 1;
416         TotalLength = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (TotalLength);
417
418         ACPI_MEMSET (ResourceSource->StringPtr, 0, TotalLength);
419
420         /* Copy the ResourceSource string to the destination */
421
422         ResourceSource->StringLength = AcpiRsStrcpy (ResourceSource->StringPtr,
423             ACPI_CAST_PTR (char, &AmlResourceSource[1]));
424
425         return ((ACPI_RS_LENGTH) TotalLength);
426     }
427
428     /* ResourceSource is not present */
429
430     ResourceSource->Index = 0;
431     ResourceSource->StringLength = 0;
432     ResourceSource->StringPtr = NULL;
433     return (0);
434 }
435
436
437 /*******************************************************************************
438  *
439  * FUNCTION:    AcpiRsSetResourceSource
440  *
441  * PARAMETERS:  Aml                 - Pointer to the raw AML descriptor
442  *              MinimumLength       - Minimum length of the descriptor (minus
443  *                                    any optional fields)
444  *              ResourceSource      - Internal ResourceSource
445
446  *
447  * RETURN:      Total length of the AML descriptor
448  *
449  * DESCRIPTION: Convert an optional ResourceSource from internal format to a
450  *              raw AML resource descriptor
451  *
452  ******************************************************************************/
453
454 ACPI_RSDESC_SIZE
455 AcpiRsSetResourceSource (
456     AML_RESOURCE            *Aml,
457     ACPI_RS_LENGTH          MinimumLength,
458     ACPI_RESOURCE_SOURCE    *ResourceSource)
459 {
460     UINT8                   *AmlResourceSource;
461     ACPI_RSDESC_SIZE        DescriptorLength;
462
463
464     ACPI_FUNCTION_ENTRY ();
465
466
467     DescriptorLength = MinimumLength;
468
469     /* Non-zero string length indicates presence of a ResourceSource */
470
471     if (ResourceSource->StringLength)
472     {
473         /* Point to the end of the AML descriptor */
474
475         AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength);
476
477         /* Copy the ResourceSourceIndex */
478
479         AmlResourceSource[0] = (UINT8) ResourceSource->Index;
480
481         /* Copy the ResourceSource string */
482
483         ACPI_STRCPY (ACPI_CAST_PTR (char, &AmlResourceSource[1]),
484             ResourceSource->StringPtr);
485
486         /*
487          * Add the length of the string (+ 1 for null terminator) to the
488          * final descriptor length
489          */
490         DescriptorLength += ((ACPI_RSDESC_SIZE) ResourceSource->StringLength + 1);
491     }
492
493     /* Return the new total length of the AML descriptor */
494
495     return (DescriptorLength);
496 }
497
498
499 /*******************************************************************************
500  *
501  * FUNCTION:    AcpiRsGetPrtMethodData
502  *
503  * PARAMETERS:  Node            - Device node
504  *              RetBuffer       - Pointer to a buffer structure for the
505  *                                results
506  *
507  * RETURN:      Status
508  *
509  * DESCRIPTION: This function is called to get the _PRT value of an object
510  *              contained in an object specified by the handle passed in
511  *
512  *              If the function fails an appropriate status will be returned
513  *              and the contents of the callers buffer is undefined.
514  *
515  ******************************************************************************/
516
517 ACPI_STATUS
518 AcpiRsGetPrtMethodData (
519     ACPI_NAMESPACE_NODE     *Node,
520     ACPI_BUFFER             *RetBuffer)
521 {
522     ACPI_OPERAND_OBJECT     *ObjDesc;
523     ACPI_STATUS             Status;
524
525
526     ACPI_FUNCTION_TRACE (RsGetPrtMethodData);
527
528
529     /* Parameters guaranteed valid by caller */
530
531     /* Execute the method, no parameters */
532
533     Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRT,
534                 ACPI_BTYPE_PACKAGE, &ObjDesc);
535     if (ACPI_FAILURE (Status))
536     {
537         return_ACPI_STATUS (Status);
538     }
539
540     /*
541      * Create a resource linked list from the byte stream buffer that comes
542      * back from the _CRS method execution.
543      */
544     Status = AcpiRsCreatePciRoutingTable (ObjDesc, RetBuffer);
545
546     /* On exit, we must delete the object returned by EvaluateObject */
547
548     AcpiUtRemoveReference (ObjDesc);
549     return_ACPI_STATUS (Status);
550 }
551
552
553 /*******************************************************************************
554  *
555  * FUNCTION:    AcpiRsGetCrsMethodData
556  *
557  * PARAMETERS:  Node            - Device node
558  *              RetBuffer       - Pointer to a buffer structure for the
559  *                                results
560  *
561  * RETURN:      Status
562  *
563  * DESCRIPTION: This function is called to get the _CRS value of an object
564  *              contained in an object specified by the handle passed in
565  *
566  *              If the function fails an appropriate status will be returned
567  *              and the contents of the callers buffer is undefined.
568  *
569  ******************************************************************************/
570
571 ACPI_STATUS
572 AcpiRsGetCrsMethodData (
573     ACPI_NAMESPACE_NODE     *Node,
574     ACPI_BUFFER             *RetBuffer)
575 {
576     ACPI_OPERAND_OBJECT     *ObjDesc;
577     ACPI_STATUS             Status;
578
579
580     ACPI_FUNCTION_TRACE (RsGetCrsMethodData);
581
582
583     /* Parameters guaranteed valid by caller */
584
585     /* Execute the method, no parameters */
586
587     Status = AcpiUtEvaluateObject (Node, METHOD_NAME__CRS,
588                 ACPI_BTYPE_BUFFER, &ObjDesc);
589     if (ACPI_FAILURE (Status))
590     {
591         return_ACPI_STATUS (Status);
592     }
593
594     /*
595      * Make the call to create a resource linked list from the
596      * byte stream buffer that comes back from the _CRS method
597      * execution.
598      */
599     Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
600
601     /* On exit, we must delete the object returned by evaluateObject */
602
603     AcpiUtRemoveReference (ObjDesc);
604     return_ACPI_STATUS (Status);
605 }
606
607
608 /*******************************************************************************
609  *
610  * FUNCTION:    AcpiRsGetPrsMethodData
611  *
612  * PARAMETERS:  Node            - Device node
613  *              RetBuffer       - Pointer to a buffer structure for the
614  *                                results
615  *
616  * RETURN:      Status
617  *
618  * DESCRIPTION: This function is called to get the _PRS value of an object
619  *              contained in an object specified by the handle passed in
620  *
621  *              If the function fails an appropriate status will be returned
622  *              and the contents of the callers buffer is undefined.
623  *
624  ******************************************************************************/
625
626 ACPI_STATUS
627 AcpiRsGetPrsMethodData (
628     ACPI_NAMESPACE_NODE     *Node,
629     ACPI_BUFFER             *RetBuffer)
630 {
631     ACPI_OPERAND_OBJECT     *ObjDesc;
632     ACPI_STATUS             Status;
633
634
635     ACPI_FUNCTION_TRACE (RsGetPrsMethodData);
636
637
638     /* Parameters guaranteed valid by caller */
639
640     /* Execute the method, no parameters */
641
642     Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRS,
643                 ACPI_BTYPE_BUFFER, &ObjDesc);
644     if (ACPI_FAILURE (Status))
645     {
646         return_ACPI_STATUS (Status);
647     }
648
649     /*
650      * Make the call to create a resource linked list from the
651      * byte stream buffer that comes back from the _CRS method
652      * execution.
653      */
654     Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
655
656     /* On exit, we must delete the object returned by evaluateObject */
657
658     AcpiUtRemoveReference (ObjDesc);
659     return_ACPI_STATUS (Status);
660 }
661
662
663 /*******************************************************************************
664  *
665  * FUNCTION:    AcpiRsGetAeiMethodData
666  *
667  * PARAMETERS:  Node            - Device node
668  *              RetBuffer       - Pointer to a buffer structure for the
669  *                                results
670  *
671  * RETURN:      Status
672  *
673  * DESCRIPTION: This function is called to get the _AEI value of an object
674  *              contained in an object specified by the handle passed in
675  *
676  *              If the function fails an appropriate status will be returned
677  *              and the contents of the callers buffer is undefined.
678  *
679  ******************************************************************************/
680
681 ACPI_STATUS
682 AcpiRsGetAeiMethodData (
683     ACPI_NAMESPACE_NODE     *Node,
684     ACPI_BUFFER             *RetBuffer)
685 {
686     ACPI_OPERAND_OBJECT     *ObjDesc;
687     ACPI_STATUS             Status;
688
689
690     ACPI_FUNCTION_TRACE (RsGetAeiMethodData);
691
692
693     /* Parameters guaranteed valid by caller */
694
695     /* Execute the method, no parameters */
696
697     Status = AcpiUtEvaluateObject (Node, METHOD_NAME__AEI,
698                 ACPI_BTYPE_BUFFER, &ObjDesc);
699     if (ACPI_FAILURE (Status))
700     {
701         return_ACPI_STATUS (Status);
702     }
703
704     /*
705      * Make the call to create a resource linked list from the
706      * byte stream buffer that comes back from the _CRS method
707      * execution.
708      */
709     Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
710
711     /* On exit, we must delete the object returned by evaluateObject */
712
713     AcpiUtRemoveReference (ObjDesc);
714     return_ACPI_STATUS (Status);
715 }
716
717
718 /*******************************************************************************
719  *
720  * FUNCTION:    AcpiRsGetMethodData
721  *
722  * PARAMETERS:  Handle          - Handle to the containing object
723  *              Path            - Path to method, relative to Handle
724  *              RetBuffer       - Pointer to a buffer structure for the
725  *                                results
726  *
727  * RETURN:      Status
728  *
729  * DESCRIPTION: This function is called to get the _CRS or _PRS value of an
730  *              object contained in an object specified by the handle passed in
731  *
732  *              If the function fails an appropriate status will be returned
733  *              and the contents of the callers buffer is undefined.
734  *
735  ******************************************************************************/
736
737 ACPI_STATUS
738 AcpiRsGetMethodData (
739     ACPI_HANDLE             Handle,
740     char                    *Path,
741     ACPI_BUFFER             *RetBuffer)
742 {
743     ACPI_OPERAND_OBJECT     *ObjDesc;
744     ACPI_STATUS             Status;
745
746
747     ACPI_FUNCTION_TRACE (RsGetMethodData);
748
749
750     /* Parameters guaranteed valid by caller */
751
752     /* Execute the method, no parameters */
753
754     Status = AcpiUtEvaluateObject (ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Handle),
755         Path, ACPI_BTYPE_BUFFER, &ObjDesc);
756     if (ACPI_FAILURE (Status))
757     {
758         return_ACPI_STATUS (Status);
759     }
760
761     /*
762      * Make the call to create a resource linked list from the
763      * byte stream buffer that comes back from the method
764      * execution.
765      */
766     Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
767
768     /* On exit, we must delete the object returned by EvaluateObject */
769
770     AcpiUtRemoveReference (ObjDesc);
771     return_ACPI_STATUS (Status);
772 }
773
774
775 /*******************************************************************************
776  *
777  * FUNCTION:    AcpiRsSetSrsMethodData
778  *
779  * PARAMETERS:  Node            - Device node
780  *              InBuffer        - Pointer to a buffer structure of the
781  *                                parameter
782  *
783  * RETURN:      Status
784  *
785  * DESCRIPTION: This function is called to set the _SRS of an object contained
786  *              in an object specified by the handle passed in
787  *
788  *              If the function fails an appropriate status will be returned
789  *              and the contents of the callers buffer is undefined.
790  *
791  * Note: Parameters guaranteed valid by caller
792  *
793  ******************************************************************************/
794
795 ACPI_STATUS
796 AcpiRsSetSrsMethodData (
797     ACPI_NAMESPACE_NODE     *Node,
798     ACPI_BUFFER             *InBuffer)
799 {
800     ACPI_EVALUATE_INFO      *Info;
801     ACPI_OPERAND_OBJECT     *Args[2];
802     ACPI_STATUS             Status;
803     ACPI_BUFFER             Buffer;
804
805
806     ACPI_FUNCTION_TRACE (RsSetSrsMethodData);
807
808
809     /* Allocate and initialize the evaluation information block */
810
811     Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
812     if (!Info)
813     {
814         return_ACPI_STATUS (AE_NO_MEMORY);
815     }
816
817     Info->PrefixNode = Node;
818     Info->RelativePathname = METHOD_NAME__SRS;
819     Info->Parameters = Args;
820     Info->Flags = ACPI_IGNORE_RETURN_VALUE;
821
822     /*
823      * The InBuffer parameter will point to a linked list of
824      * resource parameters. It needs to be formatted into a
825      * byte stream to be sent in as an input parameter to _SRS
826      *
827      * Convert the linked list into a byte stream
828      */
829     Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
830     Status = AcpiRsCreateAmlResources (InBuffer, &Buffer);
831     if (ACPI_FAILURE (Status))
832     {
833         goto Cleanup;
834     }
835
836     /* Create and initialize the method parameter object */
837
838     Args[0] = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);
839     if (!Args[0])
840     {
841         /*
842          * Must free the buffer allocated above (otherwise it is freed
843          * later)
844          */
845         ACPI_FREE (Buffer.Pointer);
846         Status = AE_NO_MEMORY;
847         goto Cleanup;
848     }
849
850     Args[0]->Buffer.Length  = (UINT32) Buffer.Length;
851     Args[0]->Buffer.Pointer = Buffer.Pointer;
852     Args[0]->Common.Flags   = AOPOBJ_DATA_VALID;
853     Args[1] = NULL;
854
855     /* Execute the method, no return value is expected */
856
857     Status = AcpiNsEvaluate (Info);
858
859     /* Clean up and return the status from AcpiNsEvaluate */
860
861     AcpiUtRemoveReference (Args[0]);
862
863 Cleanup:
864     ACPI_FREE (Info);
865     return_ACPI_STATUS (Status);
866 }