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