1433d6423SLionel Sambuc /*******************************************************************************
2433d6423SLionel Sambuc *
3433d6423SLionel Sambuc * Module Name: rsutils - Utilities for the resource manager
4433d6423SLionel Sambuc *
5433d6423SLionel Sambuc ******************************************************************************/
6433d6423SLionel Sambuc
7*29492bb7SDavid van Moolenbroek /*
8*29492bb7SDavid van Moolenbroek * Copyright (C) 2000 - 2014, Intel Corp.
9433d6423SLionel Sambuc * All rights reserved.
10433d6423SLionel Sambuc *
11*29492bb7SDavid van Moolenbroek * Redistribution and use in source and binary forms, with or without
12*29492bb7SDavid van Moolenbroek * modification, are permitted provided that the following conditions
13*29492bb7SDavid van Moolenbroek * are met:
14*29492bb7SDavid van Moolenbroek * 1. Redistributions of source code must retain the above copyright
15*29492bb7SDavid van Moolenbroek * notice, this list of conditions, and the following disclaimer,
16*29492bb7SDavid van Moolenbroek * without modification.
17*29492bb7SDavid van Moolenbroek * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18*29492bb7SDavid van Moolenbroek * substantially similar to the "NO WARRANTY" disclaimer below
19*29492bb7SDavid van Moolenbroek * ("Disclaimer") and any redistribution must be conditioned upon
20*29492bb7SDavid van Moolenbroek * including a substantially similar Disclaimer requirement for further
21*29492bb7SDavid van Moolenbroek * binary redistribution.
22*29492bb7SDavid van Moolenbroek * 3. Neither the names of the above-listed copyright holders nor the names
23*29492bb7SDavid van Moolenbroek * of any contributors may be used to endorse or promote products derived
24*29492bb7SDavid van Moolenbroek * from this software without specific prior written permission.
25433d6423SLionel Sambuc *
26*29492bb7SDavid van Moolenbroek * Alternatively, this software may be distributed under the terms of the
27*29492bb7SDavid van Moolenbroek * GNU General Public License ("GPL") version 2 as published by the Free
28*29492bb7SDavid van Moolenbroek * Software Foundation.
29433d6423SLionel Sambuc *
30*29492bb7SDavid van Moolenbroek * NO WARRANTY
31*29492bb7SDavid van Moolenbroek * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32*29492bb7SDavid van Moolenbroek * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33*29492bb7SDavid van Moolenbroek * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34*29492bb7SDavid van Moolenbroek * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35*29492bb7SDavid van Moolenbroek * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36*29492bb7SDavid van Moolenbroek * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37*29492bb7SDavid van Moolenbroek * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38*29492bb7SDavid van Moolenbroek * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39*29492bb7SDavid van Moolenbroek * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40*29492bb7SDavid van Moolenbroek * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41*29492bb7SDavid van Moolenbroek * POSSIBILITY OF SUCH DAMAGES.
42*29492bb7SDavid van Moolenbroek */
43433d6423SLionel Sambuc
44433d6423SLionel Sambuc #include "acpi.h"
45433d6423SLionel Sambuc #include "accommon.h"
46433d6423SLionel Sambuc #include "acnamesp.h"
47433d6423SLionel Sambuc #include "acresrc.h"
48433d6423SLionel Sambuc
49433d6423SLionel Sambuc
50433d6423SLionel Sambuc #define _COMPONENT ACPI_RESOURCES
51433d6423SLionel Sambuc ACPI_MODULE_NAME ("rsutils")
52433d6423SLionel Sambuc
53433d6423SLionel Sambuc
54433d6423SLionel Sambuc /*******************************************************************************
55433d6423SLionel Sambuc *
56433d6423SLionel Sambuc * FUNCTION: AcpiRsDecodeBitmask
57433d6423SLionel Sambuc *
58433d6423SLionel Sambuc * PARAMETERS: Mask - Bitmask to decode
59433d6423SLionel Sambuc * List - Where the converted list is returned
60433d6423SLionel Sambuc *
61433d6423SLionel Sambuc * RETURN: Count of bits set (length of list)
62433d6423SLionel Sambuc *
63433d6423SLionel Sambuc * DESCRIPTION: Convert a bit mask into a list of values
64433d6423SLionel Sambuc *
65433d6423SLionel Sambuc ******************************************************************************/
66433d6423SLionel Sambuc
67433d6423SLionel Sambuc UINT8
AcpiRsDecodeBitmask(UINT16 Mask,UINT8 * List)68433d6423SLionel Sambuc AcpiRsDecodeBitmask (
69433d6423SLionel Sambuc UINT16 Mask,
70433d6423SLionel Sambuc UINT8 *List)
71433d6423SLionel Sambuc {
72433d6423SLionel Sambuc UINT8 i;
73433d6423SLionel Sambuc UINT8 BitCount;
74433d6423SLionel Sambuc
75433d6423SLionel Sambuc
76433d6423SLionel Sambuc ACPI_FUNCTION_ENTRY ();
77433d6423SLionel Sambuc
78433d6423SLionel Sambuc
79433d6423SLionel Sambuc /* Decode the mask bits */
80433d6423SLionel Sambuc
81433d6423SLionel Sambuc for (i = 0, BitCount = 0; Mask; i++)
82433d6423SLionel Sambuc {
83433d6423SLionel Sambuc if (Mask & 0x0001)
84433d6423SLionel Sambuc {
85433d6423SLionel Sambuc List[BitCount] = i;
86433d6423SLionel Sambuc BitCount++;
87433d6423SLionel Sambuc }
88433d6423SLionel Sambuc
89433d6423SLionel Sambuc Mask >>= 1;
90433d6423SLionel Sambuc }
91433d6423SLionel Sambuc
92433d6423SLionel Sambuc return (BitCount);
93433d6423SLionel Sambuc }
94433d6423SLionel Sambuc
95433d6423SLionel Sambuc
96433d6423SLionel Sambuc /*******************************************************************************
97433d6423SLionel Sambuc *
98433d6423SLionel Sambuc * FUNCTION: AcpiRsEncodeBitmask
99433d6423SLionel Sambuc *
100433d6423SLionel Sambuc * PARAMETERS: List - List of values to encode
101433d6423SLionel Sambuc * Count - Length of list
102433d6423SLionel Sambuc *
103433d6423SLionel Sambuc * RETURN: Encoded bitmask
104433d6423SLionel Sambuc *
105433d6423SLionel Sambuc * DESCRIPTION: Convert a list of values to an encoded bitmask
106433d6423SLionel Sambuc *
107433d6423SLionel Sambuc ******************************************************************************/
108433d6423SLionel Sambuc
109433d6423SLionel Sambuc UINT16
AcpiRsEncodeBitmask(UINT8 * List,UINT8 Count)110433d6423SLionel Sambuc AcpiRsEncodeBitmask (
111433d6423SLionel Sambuc UINT8 *List,
112433d6423SLionel Sambuc UINT8 Count)
113433d6423SLionel Sambuc {
114433d6423SLionel Sambuc UINT32 i;
115433d6423SLionel Sambuc UINT16 Mask;
116433d6423SLionel Sambuc
117433d6423SLionel Sambuc
118433d6423SLionel Sambuc ACPI_FUNCTION_ENTRY ();
119433d6423SLionel Sambuc
120433d6423SLionel Sambuc
121433d6423SLionel Sambuc /* Encode the list into a single bitmask */
122433d6423SLionel Sambuc
123433d6423SLionel Sambuc for (i = 0, Mask = 0; i < Count; i++)
124433d6423SLionel Sambuc {
125433d6423SLionel Sambuc Mask |= (0x1 << List[i]);
126433d6423SLionel Sambuc }
127433d6423SLionel Sambuc
128433d6423SLionel Sambuc return (Mask);
129433d6423SLionel Sambuc }
130433d6423SLionel Sambuc
131433d6423SLionel Sambuc
132433d6423SLionel Sambuc /*******************************************************************************
133433d6423SLionel Sambuc *
134433d6423SLionel Sambuc * FUNCTION: AcpiRsMoveData
135433d6423SLionel Sambuc *
136433d6423SLionel Sambuc * PARAMETERS: Destination - Pointer to the destination descriptor
137433d6423SLionel Sambuc * Source - Pointer to the source descriptor
138433d6423SLionel Sambuc * ItemCount - How many items to move
139433d6423SLionel Sambuc * MoveType - Byte width
140433d6423SLionel Sambuc *
141433d6423SLionel Sambuc * RETURN: None
142433d6423SLionel Sambuc *
143433d6423SLionel Sambuc * DESCRIPTION: Move multiple data items from one descriptor to another. Handles
144433d6423SLionel Sambuc * alignment issues and endian issues if necessary, as configured
145433d6423SLionel Sambuc * via the ACPI_MOVE_* macros. (This is why a memcpy is not used)
146433d6423SLionel Sambuc *
147433d6423SLionel Sambuc ******************************************************************************/
148433d6423SLionel Sambuc
149433d6423SLionel Sambuc void
AcpiRsMoveData(void * Destination,void * Source,UINT16 ItemCount,UINT8 MoveType)150433d6423SLionel Sambuc AcpiRsMoveData (
151433d6423SLionel Sambuc void *Destination,
152433d6423SLionel Sambuc void *Source,
153433d6423SLionel Sambuc UINT16 ItemCount,
154433d6423SLionel Sambuc UINT8 MoveType)
155433d6423SLionel Sambuc {
156433d6423SLionel Sambuc UINT32 i;
157433d6423SLionel Sambuc
158433d6423SLionel Sambuc
159433d6423SLionel Sambuc ACPI_FUNCTION_ENTRY ();
160433d6423SLionel Sambuc
161433d6423SLionel Sambuc
162433d6423SLionel Sambuc /* One move per item */
163433d6423SLionel Sambuc
164433d6423SLionel Sambuc for (i = 0; i < ItemCount; i++)
165433d6423SLionel Sambuc {
166433d6423SLionel Sambuc switch (MoveType)
167433d6423SLionel Sambuc {
168433d6423SLionel Sambuc /*
169433d6423SLionel Sambuc * For the 8-bit case, we can perform the move all at once
170433d6423SLionel Sambuc * since there are no alignment or endian issues
171433d6423SLionel Sambuc */
172433d6423SLionel Sambuc case ACPI_RSC_MOVE8:
173*29492bb7SDavid van Moolenbroek case ACPI_RSC_MOVE_GPIO_RES:
174*29492bb7SDavid van Moolenbroek case ACPI_RSC_MOVE_SERIAL_VEN:
175*29492bb7SDavid van Moolenbroek case ACPI_RSC_MOVE_SERIAL_RES:
176*29492bb7SDavid van Moolenbroek
177433d6423SLionel Sambuc ACPI_MEMCPY (Destination, Source, ItemCount);
178433d6423SLionel Sambuc return;
179433d6423SLionel Sambuc
180433d6423SLionel Sambuc /*
181433d6423SLionel Sambuc * 16-, 32-, and 64-bit cases must use the move macros that perform
182*29492bb7SDavid van Moolenbroek * endian conversion and/or accommodate hardware that cannot perform
183433d6423SLionel Sambuc * misaligned memory transfers
184433d6423SLionel Sambuc */
185433d6423SLionel Sambuc case ACPI_RSC_MOVE16:
186*29492bb7SDavid van Moolenbroek case ACPI_RSC_MOVE_GPIO_PIN:
187*29492bb7SDavid van Moolenbroek
188433d6423SLionel Sambuc ACPI_MOVE_16_TO_16 (&ACPI_CAST_PTR (UINT16, Destination)[i],
189433d6423SLionel Sambuc &ACPI_CAST_PTR (UINT16, Source)[i]);
190433d6423SLionel Sambuc break;
191433d6423SLionel Sambuc
192433d6423SLionel Sambuc case ACPI_RSC_MOVE32:
193*29492bb7SDavid van Moolenbroek
194433d6423SLionel Sambuc ACPI_MOVE_32_TO_32 (&ACPI_CAST_PTR (UINT32, Destination)[i],
195433d6423SLionel Sambuc &ACPI_CAST_PTR (UINT32, Source)[i]);
196433d6423SLionel Sambuc break;
197433d6423SLionel Sambuc
198433d6423SLionel Sambuc case ACPI_RSC_MOVE64:
199*29492bb7SDavid van Moolenbroek
200433d6423SLionel Sambuc ACPI_MOVE_64_TO_64 (&ACPI_CAST_PTR (UINT64, Destination)[i],
201433d6423SLionel Sambuc &ACPI_CAST_PTR (UINT64, Source)[i]);
202433d6423SLionel Sambuc break;
203433d6423SLionel Sambuc
204433d6423SLionel Sambuc default:
205*29492bb7SDavid van Moolenbroek
206433d6423SLionel Sambuc return;
207433d6423SLionel Sambuc }
208433d6423SLionel Sambuc }
209433d6423SLionel Sambuc }
210433d6423SLionel Sambuc
211433d6423SLionel Sambuc
212433d6423SLionel Sambuc /*******************************************************************************
213433d6423SLionel Sambuc *
214433d6423SLionel Sambuc * FUNCTION: AcpiRsSetResourceLength
215433d6423SLionel Sambuc *
216433d6423SLionel Sambuc * PARAMETERS: TotalLength - Length of the AML descriptor, including
217433d6423SLionel Sambuc * the header and length fields.
218433d6423SLionel Sambuc * Aml - Pointer to the raw AML descriptor
219433d6423SLionel Sambuc *
220433d6423SLionel Sambuc * RETURN: None
221433d6423SLionel Sambuc *
222433d6423SLionel Sambuc * DESCRIPTION: Set the ResourceLength field of an AML
223433d6423SLionel Sambuc * resource descriptor, both Large and Small descriptors are
224433d6423SLionel Sambuc * supported automatically. Note: Descriptor Type field must
225433d6423SLionel Sambuc * be valid.
226433d6423SLionel Sambuc *
227433d6423SLionel Sambuc ******************************************************************************/
228433d6423SLionel Sambuc
229433d6423SLionel Sambuc void
AcpiRsSetResourceLength(ACPI_RSDESC_SIZE TotalLength,AML_RESOURCE * Aml)230433d6423SLionel Sambuc AcpiRsSetResourceLength (
231433d6423SLionel Sambuc ACPI_RSDESC_SIZE TotalLength,
232433d6423SLionel Sambuc AML_RESOURCE *Aml)
233433d6423SLionel Sambuc {
234433d6423SLionel Sambuc ACPI_RS_LENGTH ResourceLength;
235433d6423SLionel Sambuc
236433d6423SLionel Sambuc
237433d6423SLionel Sambuc ACPI_FUNCTION_ENTRY ();
238433d6423SLionel Sambuc
239433d6423SLionel Sambuc
240433d6423SLionel Sambuc /* Length is the total descriptor length minus the header length */
241433d6423SLionel Sambuc
242433d6423SLionel Sambuc ResourceLength = (ACPI_RS_LENGTH)
243433d6423SLionel Sambuc (TotalLength - AcpiUtGetResourceHeaderLength (Aml));
244433d6423SLionel Sambuc
245433d6423SLionel Sambuc /* Length is stored differently for large and small descriptors */
246433d6423SLionel Sambuc
247433d6423SLionel Sambuc if (Aml->SmallHeader.DescriptorType & ACPI_RESOURCE_NAME_LARGE)
248433d6423SLionel Sambuc {
249433d6423SLionel Sambuc /* Large descriptor -- bytes 1-2 contain the 16-bit length */
250433d6423SLionel Sambuc
251433d6423SLionel Sambuc ACPI_MOVE_16_TO_16 (&Aml->LargeHeader.ResourceLength, &ResourceLength);
252433d6423SLionel Sambuc }
253433d6423SLionel Sambuc else
254433d6423SLionel Sambuc {
255433d6423SLionel Sambuc /* Small descriptor -- bits 2:0 of byte 0 contain the length */
256433d6423SLionel Sambuc
257433d6423SLionel Sambuc Aml->SmallHeader.DescriptorType = (UINT8)
258433d6423SLionel Sambuc
259433d6423SLionel Sambuc /* Clear any existing length, preserving descriptor type bits */
260433d6423SLionel Sambuc
261433d6423SLionel Sambuc ((Aml->SmallHeader.DescriptorType & ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK)
262433d6423SLionel Sambuc
263433d6423SLionel Sambuc | ResourceLength);
264433d6423SLionel Sambuc }
265433d6423SLionel Sambuc }
266433d6423SLionel Sambuc
267433d6423SLionel Sambuc
268433d6423SLionel Sambuc /*******************************************************************************
269433d6423SLionel Sambuc *
270433d6423SLionel Sambuc * FUNCTION: AcpiRsSetResourceHeader
271433d6423SLionel Sambuc *
272433d6423SLionel Sambuc * PARAMETERS: DescriptorType - Byte to be inserted as the type
273433d6423SLionel Sambuc * TotalLength - Length of the AML descriptor, including
274433d6423SLionel Sambuc * the header and length fields.
275433d6423SLionel Sambuc * Aml - Pointer to the raw AML descriptor
276433d6423SLionel Sambuc *
277433d6423SLionel Sambuc * RETURN: None
278433d6423SLionel Sambuc *
279433d6423SLionel Sambuc * DESCRIPTION: Set the DescriptorType and ResourceLength fields of an AML
280433d6423SLionel Sambuc * resource descriptor, both Large and Small descriptors are
281433d6423SLionel Sambuc * supported automatically
282433d6423SLionel Sambuc *
283433d6423SLionel Sambuc ******************************************************************************/
284433d6423SLionel Sambuc
285433d6423SLionel Sambuc void
AcpiRsSetResourceHeader(UINT8 DescriptorType,ACPI_RSDESC_SIZE TotalLength,AML_RESOURCE * Aml)286433d6423SLionel Sambuc AcpiRsSetResourceHeader (
287433d6423SLionel Sambuc UINT8 DescriptorType,
288433d6423SLionel Sambuc ACPI_RSDESC_SIZE TotalLength,
289433d6423SLionel Sambuc AML_RESOURCE *Aml)
290433d6423SLionel Sambuc {
291433d6423SLionel Sambuc ACPI_FUNCTION_ENTRY ();
292433d6423SLionel Sambuc
293433d6423SLionel Sambuc
294433d6423SLionel Sambuc /* Set the Resource Type */
295433d6423SLionel Sambuc
296433d6423SLionel Sambuc Aml->SmallHeader.DescriptorType = DescriptorType;
297433d6423SLionel Sambuc
298433d6423SLionel Sambuc /* Set the Resource Length */
299433d6423SLionel Sambuc
300433d6423SLionel Sambuc AcpiRsSetResourceLength (TotalLength, Aml);
301433d6423SLionel Sambuc }
302433d6423SLionel Sambuc
303433d6423SLionel Sambuc
304433d6423SLionel Sambuc /*******************************************************************************
305433d6423SLionel Sambuc *
306433d6423SLionel Sambuc * FUNCTION: AcpiRsStrcpy
307433d6423SLionel Sambuc *
308433d6423SLionel Sambuc * PARAMETERS: Destination - Pointer to the destination string
309433d6423SLionel Sambuc * Source - Pointer to the source string
310433d6423SLionel Sambuc *
311433d6423SLionel Sambuc * RETURN: String length, including NULL terminator
312433d6423SLionel Sambuc *
313433d6423SLionel Sambuc * DESCRIPTION: Local string copy that returns the string length, saving a
314433d6423SLionel Sambuc * strcpy followed by a strlen.
315433d6423SLionel Sambuc *
316433d6423SLionel Sambuc ******************************************************************************/
317433d6423SLionel Sambuc
318433d6423SLionel Sambuc static UINT16
AcpiRsStrcpy(char * Destination,char * Source)319433d6423SLionel Sambuc AcpiRsStrcpy (
320433d6423SLionel Sambuc char *Destination,
321433d6423SLionel Sambuc char *Source)
322433d6423SLionel Sambuc {
323433d6423SLionel Sambuc UINT16 i;
324433d6423SLionel Sambuc
325433d6423SLionel Sambuc
326433d6423SLionel Sambuc ACPI_FUNCTION_ENTRY ();
327433d6423SLionel Sambuc
328433d6423SLionel Sambuc
329433d6423SLionel Sambuc for (i = 0; Source[i]; i++)
330433d6423SLionel Sambuc {
331433d6423SLionel Sambuc Destination[i] = Source[i];
332433d6423SLionel Sambuc }
333433d6423SLionel Sambuc
334433d6423SLionel Sambuc Destination[i] = 0;
335433d6423SLionel Sambuc
336433d6423SLionel Sambuc /* Return string length including the NULL terminator */
337433d6423SLionel Sambuc
338433d6423SLionel Sambuc return ((UINT16) (i + 1));
339433d6423SLionel Sambuc }
340433d6423SLionel Sambuc
341433d6423SLionel Sambuc
342433d6423SLionel Sambuc /*******************************************************************************
343433d6423SLionel Sambuc *
344433d6423SLionel Sambuc * FUNCTION: AcpiRsGetResourceSource
345433d6423SLionel Sambuc *
346433d6423SLionel Sambuc * PARAMETERS: ResourceLength - Length field of the descriptor
347433d6423SLionel Sambuc * MinimumLength - Minimum length of the descriptor (minus
348433d6423SLionel Sambuc * any optional fields)
349433d6423SLionel Sambuc * ResourceSource - Where the ResourceSource is returned
350433d6423SLionel Sambuc * Aml - Pointer to the raw AML descriptor
351433d6423SLionel Sambuc * StringPtr - (optional) where to store the actual
352433d6423SLionel Sambuc * ResourceSource string
353433d6423SLionel Sambuc *
354433d6423SLionel Sambuc * RETURN: Length of the string plus NULL terminator, rounded up to native
355433d6423SLionel Sambuc * word boundary
356433d6423SLionel Sambuc *
357433d6423SLionel Sambuc * DESCRIPTION: Copy the optional ResourceSource data from a raw AML descriptor
358433d6423SLionel Sambuc * to an internal resource descriptor
359433d6423SLionel Sambuc *
360433d6423SLionel Sambuc ******************************************************************************/
361433d6423SLionel Sambuc
362433d6423SLionel Sambuc ACPI_RS_LENGTH
AcpiRsGetResourceSource(ACPI_RS_LENGTH ResourceLength,ACPI_RS_LENGTH MinimumLength,ACPI_RESOURCE_SOURCE * ResourceSource,AML_RESOURCE * Aml,char * StringPtr)363433d6423SLionel Sambuc AcpiRsGetResourceSource (
364433d6423SLionel Sambuc ACPI_RS_LENGTH ResourceLength,
365433d6423SLionel Sambuc ACPI_RS_LENGTH MinimumLength,
366433d6423SLionel Sambuc ACPI_RESOURCE_SOURCE *ResourceSource,
367433d6423SLionel Sambuc AML_RESOURCE *Aml,
368433d6423SLionel Sambuc char *StringPtr)
369433d6423SLionel Sambuc {
370433d6423SLionel Sambuc ACPI_RSDESC_SIZE TotalLength;
371433d6423SLionel Sambuc UINT8 *AmlResourceSource;
372433d6423SLionel Sambuc
373433d6423SLionel Sambuc
374433d6423SLionel Sambuc ACPI_FUNCTION_ENTRY ();
375433d6423SLionel Sambuc
376433d6423SLionel Sambuc
377433d6423SLionel Sambuc TotalLength = ResourceLength + sizeof (AML_RESOURCE_LARGE_HEADER);
378433d6423SLionel Sambuc AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength);
379433d6423SLionel Sambuc
380433d6423SLionel Sambuc /*
381433d6423SLionel Sambuc * ResourceSource is present if the length of the descriptor is longer than
382433d6423SLionel Sambuc * the minimum length.
383433d6423SLionel Sambuc *
384433d6423SLionel Sambuc * Note: Some resource descriptors will have an additional null, so
385433d6423SLionel Sambuc * we add 1 to the minimum length.
386433d6423SLionel Sambuc */
387433d6423SLionel Sambuc if (TotalLength > (ACPI_RSDESC_SIZE) (MinimumLength + 1))
388433d6423SLionel Sambuc {
389433d6423SLionel Sambuc /* Get the ResourceSourceIndex */
390433d6423SLionel Sambuc
391433d6423SLionel Sambuc ResourceSource->Index = AmlResourceSource[0];
392433d6423SLionel Sambuc
393433d6423SLionel Sambuc ResourceSource->StringPtr = StringPtr;
394433d6423SLionel Sambuc if (!StringPtr)
395433d6423SLionel Sambuc {
396433d6423SLionel Sambuc /*
397433d6423SLionel Sambuc * String destination pointer is not specified; Set the String
398433d6423SLionel Sambuc * pointer to the end of the current ResourceSource structure.
399433d6423SLionel Sambuc */
400433d6423SLionel Sambuc ResourceSource->StringPtr = ACPI_ADD_PTR (char, ResourceSource,
401433d6423SLionel Sambuc sizeof (ACPI_RESOURCE_SOURCE));
402433d6423SLionel Sambuc }
403433d6423SLionel Sambuc
404433d6423SLionel Sambuc /*
405433d6423SLionel Sambuc * In order for the Resource length to be a multiple of the native
406433d6423SLionel Sambuc * word, calculate the length of the string (+1 for NULL terminator)
407433d6423SLionel Sambuc * and expand to the next word multiple.
408433d6423SLionel Sambuc *
409433d6423SLionel Sambuc * Zero the entire area of the buffer.
410433d6423SLionel Sambuc */
411433d6423SLionel Sambuc TotalLength = (UINT32) ACPI_STRLEN (
412433d6423SLionel Sambuc ACPI_CAST_PTR (char, &AmlResourceSource[1])) + 1;
413433d6423SLionel Sambuc TotalLength = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (TotalLength);
414433d6423SLionel Sambuc
415433d6423SLionel Sambuc ACPI_MEMSET (ResourceSource->StringPtr, 0, TotalLength);
416433d6423SLionel Sambuc
417433d6423SLionel Sambuc /* Copy the ResourceSource string to the destination */
418433d6423SLionel Sambuc
419433d6423SLionel Sambuc ResourceSource->StringLength = AcpiRsStrcpy (ResourceSource->StringPtr,
420433d6423SLionel Sambuc ACPI_CAST_PTR (char, &AmlResourceSource[1]));
421433d6423SLionel Sambuc
422433d6423SLionel Sambuc return ((ACPI_RS_LENGTH) TotalLength);
423433d6423SLionel Sambuc }
424433d6423SLionel Sambuc
425433d6423SLionel Sambuc /* ResourceSource is not present */
426433d6423SLionel Sambuc
427433d6423SLionel Sambuc ResourceSource->Index = 0;
428433d6423SLionel Sambuc ResourceSource->StringLength = 0;
429433d6423SLionel Sambuc ResourceSource->StringPtr = NULL;
430433d6423SLionel Sambuc return (0);
431433d6423SLionel Sambuc }
432433d6423SLionel Sambuc
433433d6423SLionel Sambuc
434433d6423SLionel Sambuc /*******************************************************************************
435433d6423SLionel Sambuc *
436433d6423SLionel Sambuc * FUNCTION: AcpiRsSetResourceSource
437433d6423SLionel Sambuc *
438433d6423SLionel Sambuc * PARAMETERS: Aml - Pointer to the raw AML descriptor
439433d6423SLionel Sambuc * MinimumLength - Minimum length of the descriptor (minus
440433d6423SLionel Sambuc * any optional fields)
441433d6423SLionel Sambuc * ResourceSource - Internal ResourceSource
442433d6423SLionel Sambuc
443433d6423SLionel Sambuc *
444433d6423SLionel Sambuc * RETURN: Total length of the AML descriptor
445433d6423SLionel Sambuc *
446433d6423SLionel Sambuc * DESCRIPTION: Convert an optional ResourceSource from internal format to a
447433d6423SLionel Sambuc * raw AML resource descriptor
448433d6423SLionel Sambuc *
449433d6423SLionel Sambuc ******************************************************************************/
450433d6423SLionel Sambuc
451433d6423SLionel Sambuc ACPI_RSDESC_SIZE
AcpiRsSetResourceSource(AML_RESOURCE * Aml,ACPI_RS_LENGTH MinimumLength,ACPI_RESOURCE_SOURCE * ResourceSource)452433d6423SLionel Sambuc AcpiRsSetResourceSource (
453433d6423SLionel Sambuc AML_RESOURCE *Aml,
454433d6423SLionel Sambuc ACPI_RS_LENGTH MinimumLength,
455433d6423SLionel Sambuc ACPI_RESOURCE_SOURCE *ResourceSource)
456433d6423SLionel Sambuc {
457433d6423SLionel Sambuc UINT8 *AmlResourceSource;
458433d6423SLionel Sambuc ACPI_RSDESC_SIZE DescriptorLength;
459433d6423SLionel Sambuc
460433d6423SLionel Sambuc
461433d6423SLionel Sambuc ACPI_FUNCTION_ENTRY ();
462433d6423SLionel Sambuc
463433d6423SLionel Sambuc
464433d6423SLionel Sambuc DescriptorLength = MinimumLength;
465433d6423SLionel Sambuc
466433d6423SLionel Sambuc /* Non-zero string length indicates presence of a ResourceSource */
467433d6423SLionel Sambuc
468433d6423SLionel Sambuc if (ResourceSource->StringLength)
469433d6423SLionel Sambuc {
470433d6423SLionel Sambuc /* Point to the end of the AML descriptor */
471433d6423SLionel Sambuc
472433d6423SLionel Sambuc AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength);
473433d6423SLionel Sambuc
474433d6423SLionel Sambuc /* Copy the ResourceSourceIndex */
475433d6423SLionel Sambuc
476433d6423SLionel Sambuc AmlResourceSource[0] = (UINT8) ResourceSource->Index;
477433d6423SLionel Sambuc
478433d6423SLionel Sambuc /* Copy the ResourceSource string */
479433d6423SLionel Sambuc
480433d6423SLionel Sambuc ACPI_STRCPY (ACPI_CAST_PTR (char, &AmlResourceSource[1]),
481433d6423SLionel Sambuc ResourceSource->StringPtr);
482433d6423SLionel Sambuc
483433d6423SLionel Sambuc /*
484433d6423SLionel Sambuc * Add the length of the string (+ 1 for null terminator) to the
485433d6423SLionel Sambuc * final descriptor length
486433d6423SLionel Sambuc */
487433d6423SLionel Sambuc DescriptorLength += ((ACPI_RSDESC_SIZE) ResourceSource->StringLength + 1);
488433d6423SLionel Sambuc }
489433d6423SLionel Sambuc
490433d6423SLionel Sambuc /* Return the new total length of the AML descriptor */
491433d6423SLionel Sambuc
492433d6423SLionel Sambuc return (DescriptorLength);
493433d6423SLionel Sambuc }
494433d6423SLionel Sambuc
495433d6423SLionel Sambuc
496433d6423SLionel Sambuc /*******************************************************************************
497433d6423SLionel Sambuc *
498433d6423SLionel Sambuc * FUNCTION: AcpiRsGetPrtMethodData
499433d6423SLionel Sambuc *
500433d6423SLionel Sambuc * PARAMETERS: Node - Device node
501433d6423SLionel Sambuc * RetBuffer - Pointer to a buffer structure for the
502433d6423SLionel Sambuc * results
503433d6423SLionel Sambuc *
504433d6423SLionel Sambuc * RETURN: Status
505433d6423SLionel Sambuc *
506433d6423SLionel Sambuc * DESCRIPTION: This function is called to get the _PRT value of an object
507433d6423SLionel Sambuc * contained in an object specified by the handle passed in
508433d6423SLionel Sambuc *
509433d6423SLionel Sambuc * If the function fails an appropriate status will be returned
510433d6423SLionel Sambuc * and the contents of the callers buffer is undefined.
511433d6423SLionel Sambuc *
512433d6423SLionel Sambuc ******************************************************************************/
513433d6423SLionel Sambuc
514433d6423SLionel Sambuc ACPI_STATUS
AcpiRsGetPrtMethodData(ACPI_NAMESPACE_NODE * Node,ACPI_BUFFER * RetBuffer)515433d6423SLionel Sambuc AcpiRsGetPrtMethodData (
516433d6423SLionel Sambuc ACPI_NAMESPACE_NODE *Node,
517433d6423SLionel Sambuc ACPI_BUFFER *RetBuffer)
518433d6423SLionel Sambuc {
519433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *ObjDesc;
520433d6423SLionel Sambuc ACPI_STATUS Status;
521433d6423SLionel Sambuc
522433d6423SLionel Sambuc
523433d6423SLionel Sambuc ACPI_FUNCTION_TRACE (RsGetPrtMethodData);
524433d6423SLionel Sambuc
525433d6423SLionel Sambuc
526433d6423SLionel Sambuc /* Parameters guaranteed valid by caller */
527433d6423SLionel Sambuc
528433d6423SLionel Sambuc /* Execute the method, no parameters */
529433d6423SLionel Sambuc
530433d6423SLionel Sambuc Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRT,
531433d6423SLionel Sambuc ACPI_BTYPE_PACKAGE, &ObjDesc);
532433d6423SLionel Sambuc if (ACPI_FAILURE (Status))
533433d6423SLionel Sambuc {
534433d6423SLionel Sambuc return_ACPI_STATUS (Status);
535433d6423SLionel Sambuc }
536433d6423SLionel Sambuc
537433d6423SLionel Sambuc /*
538433d6423SLionel Sambuc * Create a resource linked list from the byte stream buffer that comes
539433d6423SLionel Sambuc * back from the _CRS method execution.
540433d6423SLionel Sambuc */
541433d6423SLionel Sambuc Status = AcpiRsCreatePciRoutingTable (ObjDesc, RetBuffer);
542433d6423SLionel Sambuc
543433d6423SLionel Sambuc /* On exit, we must delete the object returned by EvaluateObject */
544433d6423SLionel Sambuc
545433d6423SLionel Sambuc AcpiUtRemoveReference (ObjDesc);
546433d6423SLionel Sambuc return_ACPI_STATUS (Status);
547433d6423SLionel Sambuc }
548433d6423SLionel Sambuc
549433d6423SLionel Sambuc
550433d6423SLionel Sambuc /*******************************************************************************
551433d6423SLionel Sambuc *
552433d6423SLionel Sambuc * FUNCTION: AcpiRsGetCrsMethodData
553433d6423SLionel Sambuc *
554433d6423SLionel Sambuc * PARAMETERS: Node - Device node
555433d6423SLionel Sambuc * RetBuffer - Pointer to a buffer structure for the
556433d6423SLionel Sambuc * results
557433d6423SLionel Sambuc *
558433d6423SLionel Sambuc * RETURN: Status
559433d6423SLionel Sambuc *
560433d6423SLionel Sambuc * DESCRIPTION: This function is called to get the _CRS value of an object
561433d6423SLionel Sambuc * contained in an object specified by the handle passed in
562433d6423SLionel Sambuc *
563433d6423SLionel Sambuc * If the function fails an appropriate status will be returned
564433d6423SLionel Sambuc * and the contents of the callers buffer is undefined.
565433d6423SLionel Sambuc *
566433d6423SLionel Sambuc ******************************************************************************/
567433d6423SLionel Sambuc
568433d6423SLionel Sambuc ACPI_STATUS
AcpiRsGetCrsMethodData(ACPI_NAMESPACE_NODE * Node,ACPI_BUFFER * RetBuffer)569433d6423SLionel Sambuc AcpiRsGetCrsMethodData (
570433d6423SLionel Sambuc ACPI_NAMESPACE_NODE *Node,
571433d6423SLionel Sambuc ACPI_BUFFER *RetBuffer)
572433d6423SLionel Sambuc {
573433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *ObjDesc;
574433d6423SLionel Sambuc ACPI_STATUS Status;
575433d6423SLionel Sambuc
576433d6423SLionel Sambuc
577433d6423SLionel Sambuc ACPI_FUNCTION_TRACE (RsGetCrsMethodData);
578433d6423SLionel Sambuc
579433d6423SLionel Sambuc
580433d6423SLionel Sambuc /* Parameters guaranteed valid by caller */
581433d6423SLionel Sambuc
582433d6423SLionel Sambuc /* Execute the method, no parameters */
583433d6423SLionel Sambuc
584433d6423SLionel Sambuc Status = AcpiUtEvaluateObject (Node, METHOD_NAME__CRS,
585433d6423SLionel Sambuc ACPI_BTYPE_BUFFER, &ObjDesc);
586433d6423SLionel Sambuc if (ACPI_FAILURE (Status))
587433d6423SLionel Sambuc {
588433d6423SLionel Sambuc return_ACPI_STATUS (Status);
589433d6423SLionel Sambuc }
590433d6423SLionel Sambuc
591433d6423SLionel Sambuc /*
592433d6423SLionel Sambuc * Make the call to create a resource linked list from the
593433d6423SLionel Sambuc * byte stream buffer that comes back from the _CRS method
594433d6423SLionel Sambuc * execution.
595433d6423SLionel Sambuc */
596433d6423SLionel Sambuc Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
597433d6423SLionel Sambuc
598433d6423SLionel Sambuc /* On exit, we must delete the object returned by evaluateObject */
599433d6423SLionel Sambuc
600433d6423SLionel Sambuc AcpiUtRemoveReference (ObjDesc);
601433d6423SLionel Sambuc return_ACPI_STATUS (Status);
602433d6423SLionel Sambuc }
603433d6423SLionel Sambuc
604433d6423SLionel Sambuc
605433d6423SLionel Sambuc /*******************************************************************************
606433d6423SLionel Sambuc *
607433d6423SLionel Sambuc * FUNCTION: AcpiRsGetPrsMethodData
608433d6423SLionel Sambuc *
609433d6423SLionel Sambuc * PARAMETERS: Node - Device node
610433d6423SLionel Sambuc * RetBuffer - Pointer to a buffer structure for the
611433d6423SLionel Sambuc * results
612433d6423SLionel Sambuc *
613433d6423SLionel Sambuc * RETURN: Status
614433d6423SLionel Sambuc *
615433d6423SLionel Sambuc * DESCRIPTION: This function is called to get the _PRS value of an object
616433d6423SLionel Sambuc * contained in an object specified by the handle passed in
617433d6423SLionel Sambuc *
618433d6423SLionel Sambuc * If the function fails an appropriate status will be returned
619433d6423SLionel Sambuc * and the contents of the callers buffer is undefined.
620433d6423SLionel Sambuc *
621433d6423SLionel Sambuc ******************************************************************************/
622433d6423SLionel Sambuc
623433d6423SLionel Sambuc ACPI_STATUS
AcpiRsGetPrsMethodData(ACPI_NAMESPACE_NODE * Node,ACPI_BUFFER * RetBuffer)624433d6423SLionel Sambuc AcpiRsGetPrsMethodData (
625433d6423SLionel Sambuc ACPI_NAMESPACE_NODE *Node,
626433d6423SLionel Sambuc ACPI_BUFFER *RetBuffer)
627433d6423SLionel Sambuc {
628433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *ObjDesc;
629433d6423SLionel Sambuc ACPI_STATUS Status;
630433d6423SLionel Sambuc
631433d6423SLionel Sambuc
632433d6423SLionel Sambuc ACPI_FUNCTION_TRACE (RsGetPrsMethodData);
633433d6423SLionel Sambuc
634433d6423SLionel Sambuc
635433d6423SLionel Sambuc /* Parameters guaranteed valid by caller */
636433d6423SLionel Sambuc
637433d6423SLionel Sambuc /* Execute the method, no parameters */
638433d6423SLionel Sambuc
639433d6423SLionel Sambuc Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRS,
640433d6423SLionel Sambuc ACPI_BTYPE_BUFFER, &ObjDesc);
641433d6423SLionel Sambuc if (ACPI_FAILURE (Status))
642433d6423SLionel Sambuc {
643433d6423SLionel Sambuc return_ACPI_STATUS (Status);
644433d6423SLionel Sambuc }
645433d6423SLionel Sambuc
646433d6423SLionel Sambuc /*
647433d6423SLionel Sambuc * Make the call to create a resource linked list from the
648433d6423SLionel Sambuc * byte stream buffer that comes back from the _CRS method
649433d6423SLionel Sambuc * execution.
650433d6423SLionel Sambuc */
651433d6423SLionel Sambuc Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
652433d6423SLionel Sambuc
653433d6423SLionel Sambuc /* On exit, we must delete the object returned by evaluateObject */
654433d6423SLionel Sambuc
655433d6423SLionel Sambuc AcpiUtRemoveReference (ObjDesc);
656433d6423SLionel Sambuc return_ACPI_STATUS (Status);
657433d6423SLionel Sambuc }
658433d6423SLionel Sambuc
659433d6423SLionel Sambuc
660433d6423SLionel Sambuc /*******************************************************************************
661433d6423SLionel Sambuc *
662*29492bb7SDavid van Moolenbroek * FUNCTION: AcpiRsGetAeiMethodData
663*29492bb7SDavid van Moolenbroek *
664*29492bb7SDavid van Moolenbroek * PARAMETERS: Node - Device node
665*29492bb7SDavid van Moolenbroek * RetBuffer - Pointer to a buffer structure for the
666*29492bb7SDavid van Moolenbroek * results
667*29492bb7SDavid van Moolenbroek *
668*29492bb7SDavid van Moolenbroek * RETURN: Status
669*29492bb7SDavid van Moolenbroek *
670*29492bb7SDavid van Moolenbroek * DESCRIPTION: This function is called to get the _AEI value of an object
671*29492bb7SDavid van Moolenbroek * contained in an object specified by the handle passed in
672*29492bb7SDavid van Moolenbroek *
673*29492bb7SDavid van Moolenbroek * If the function fails an appropriate status will be returned
674*29492bb7SDavid van Moolenbroek * and the contents of the callers buffer is undefined.
675*29492bb7SDavid van Moolenbroek *
676*29492bb7SDavid van Moolenbroek ******************************************************************************/
677*29492bb7SDavid van Moolenbroek
678*29492bb7SDavid van Moolenbroek ACPI_STATUS
AcpiRsGetAeiMethodData(ACPI_NAMESPACE_NODE * Node,ACPI_BUFFER * RetBuffer)679*29492bb7SDavid van Moolenbroek AcpiRsGetAeiMethodData (
680*29492bb7SDavid van Moolenbroek ACPI_NAMESPACE_NODE *Node,
681*29492bb7SDavid van Moolenbroek ACPI_BUFFER *RetBuffer)
682*29492bb7SDavid van Moolenbroek {
683*29492bb7SDavid van Moolenbroek ACPI_OPERAND_OBJECT *ObjDesc;
684*29492bb7SDavid van Moolenbroek ACPI_STATUS Status;
685*29492bb7SDavid van Moolenbroek
686*29492bb7SDavid van Moolenbroek
687*29492bb7SDavid van Moolenbroek ACPI_FUNCTION_TRACE (RsGetAeiMethodData);
688*29492bb7SDavid van Moolenbroek
689*29492bb7SDavid van Moolenbroek
690*29492bb7SDavid van Moolenbroek /* Parameters guaranteed valid by caller */
691*29492bb7SDavid van Moolenbroek
692*29492bb7SDavid van Moolenbroek /* Execute the method, no parameters */
693*29492bb7SDavid van Moolenbroek
694*29492bb7SDavid van Moolenbroek Status = AcpiUtEvaluateObject (Node, METHOD_NAME__AEI,
695*29492bb7SDavid van Moolenbroek ACPI_BTYPE_BUFFER, &ObjDesc);
696*29492bb7SDavid van Moolenbroek if (ACPI_FAILURE (Status))
697*29492bb7SDavid van Moolenbroek {
698*29492bb7SDavid van Moolenbroek return_ACPI_STATUS (Status);
699*29492bb7SDavid van Moolenbroek }
700*29492bb7SDavid van Moolenbroek
701*29492bb7SDavid van Moolenbroek /*
702*29492bb7SDavid van Moolenbroek * Make the call to create a resource linked list from the
703*29492bb7SDavid van Moolenbroek * byte stream buffer that comes back from the _CRS method
704*29492bb7SDavid van Moolenbroek * execution.
705*29492bb7SDavid van Moolenbroek */
706*29492bb7SDavid van Moolenbroek Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
707*29492bb7SDavid van Moolenbroek
708*29492bb7SDavid van Moolenbroek /* On exit, we must delete the object returned by evaluateObject */
709*29492bb7SDavid van Moolenbroek
710*29492bb7SDavid van Moolenbroek AcpiUtRemoveReference (ObjDesc);
711*29492bb7SDavid van Moolenbroek return_ACPI_STATUS (Status);
712*29492bb7SDavid van Moolenbroek }
713*29492bb7SDavid van Moolenbroek
714*29492bb7SDavid van Moolenbroek
715*29492bb7SDavid van Moolenbroek /*******************************************************************************
716*29492bb7SDavid van Moolenbroek *
717433d6423SLionel Sambuc * FUNCTION: AcpiRsGetMethodData
718433d6423SLionel Sambuc *
719433d6423SLionel Sambuc * PARAMETERS: Handle - Handle to the containing object
720433d6423SLionel Sambuc * Path - Path to method, relative to Handle
721433d6423SLionel Sambuc * RetBuffer - Pointer to a buffer structure for the
722433d6423SLionel Sambuc * results
723433d6423SLionel Sambuc *
724433d6423SLionel Sambuc * RETURN: Status
725433d6423SLionel Sambuc *
726433d6423SLionel Sambuc * DESCRIPTION: This function is called to get the _CRS or _PRS value of an
727433d6423SLionel Sambuc * object contained in an object specified by the handle passed in
728433d6423SLionel Sambuc *
729433d6423SLionel Sambuc * If the function fails an appropriate status will be returned
730433d6423SLionel Sambuc * and the contents of the callers buffer is undefined.
731433d6423SLionel Sambuc *
732433d6423SLionel Sambuc ******************************************************************************/
733433d6423SLionel Sambuc
734433d6423SLionel Sambuc ACPI_STATUS
AcpiRsGetMethodData(ACPI_HANDLE Handle,char * Path,ACPI_BUFFER * RetBuffer)735433d6423SLionel Sambuc AcpiRsGetMethodData (
736433d6423SLionel Sambuc ACPI_HANDLE Handle,
737433d6423SLionel Sambuc char *Path,
738433d6423SLionel Sambuc ACPI_BUFFER *RetBuffer)
739433d6423SLionel Sambuc {
740433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *ObjDesc;
741433d6423SLionel Sambuc ACPI_STATUS Status;
742433d6423SLionel Sambuc
743433d6423SLionel Sambuc
744433d6423SLionel Sambuc ACPI_FUNCTION_TRACE (RsGetMethodData);
745433d6423SLionel Sambuc
746433d6423SLionel Sambuc
747433d6423SLionel Sambuc /* Parameters guaranteed valid by caller */
748433d6423SLionel Sambuc
749433d6423SLionel Sambuc /* Execute the method, no parameters */
750433d6423SLionel Sambuc
751*29492bb7SDavid van Moolenbroek Status = AcpiUtEvaluateObject (ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Handle),
752*29492bb7SDavid van Moolenbroek Path, ACPI_BTYPE_BUFFER, &ObjDesc);
753433d6423SLionel Sambuc if (ACPI_FAILURE (Status))
754433d6423SLionel Sambuc {
755433d6423SLionel Sambuc return_ACPI_STATUS (Status);
756433d6423SLionel Sambuc }
757433d6423SLionel Sambuc
758433d6423SLionel Sambuc /*
759433d6423SLionel Sambuc * Make the call to create a resource linked list from the
760433d6423SLionel Sambuc * byte stream buffer that comes back from the method
761433d6423SLionel Sambuc * execution.
762433d6423SLionel Sambuc */
763433d6423SLionel Sambuc Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
764433d6423SLionel Sambuc
765433d6423SLionel Sambuc /* On exit, we must delete the object returned by EvaluateObject */
766433d6423SLionel Sambuc
767433d6423SLionel Sambuc AcpiUtRemoveReference (ObjDesc);
768433d6423SLionel Sambuc return_ACPI_STATUS (Status);
769433d6423SLionel Sambuc }
770433d6423SLionel Sambuc
771433d6423SLionel Sambuc
772433d6423SLionel Sambuc /*******************************************************************************
773433d6423SLionel Sambuc *
774433d6423SLionel Sambuc * FUNCTION: AcpiRsSetSrsMethodData
775433d6423SLionel Sambuc *
776433d6423SLionel Sambuc * PARAMETERS: Node - Device node
777433d6423SLionel Sambuc * InBuffer - Pointer to a buffer structure of the
778433d6423SLionel Sambuc * parameter
779433d6423SLionel Sambuc *
780433d6423SLionel Sambuc * RETURN: Status
781433d6423SLionel Sambuc *
782433d6423SLionel Sambuc * DESCRIPTION: This function is called to set the _SRS of an object contained
783433d6423SLionel Sambuc * in an object specified by the handle passed in
784433d6423SLionel Sambuc *
785433d6423SLionel Sambuc * If the function fails an appropriate status will be returned
786433d6423SLionel Sambuc * and the contents of the callers buffer is undefined.
787433d6423SLionel Sambuc *
788433d6423SLionel Sambuc * Note: Parameters guaranteed valid by caller
789433d6423SLionel Sambuc *
790433d6423SLionel Sambuc ******************************************************************************/
791433d6423SLionel Sambuc
792433d6423SLionel Sambuc ACPI_STATUS
AcpiRsSetSrsMethodData(ACPI_NAMESPACE_NODE * Node,ACPI_BUFFER * InBuffer)793433d6423SLionel Sambuc AcpiRsSetSrsMethodData (
794433d6423SLionel Sambuc ACPI_NAMESPACE_NODE *Node,
795433d6423SLionel Sambuc ACPI_BUFFER *InBuffer)
796433d6423SLionel Sambuc {
797433d6423SLionel Sambuc ACPI_EVALUATE_INFO *Info;
798433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *Args[2];
799433d6423SLionel Sambuc ACPI_STATUS Status;
800433d6423SLionel Sambuc ACPI_BUFFER Buffer;
801433d6423SLionel Sambuc
802433d6423SLionel Sambuc
803433d6423SLionel Sambuc ACPI_FUNCTION_TRACE (RsSetSrsMethodData);
804433d6423SLionel Sambuc
805433d6423SLionel Sambuc
806433d6423SLionel Sambuc /* Allocate and initialize the evaluation information block */
807433d6423SLionel Sambuc
808433d6423SLionel Sambuc Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
809433d6423SLionel Sambuc if (!Info)
810433d6423SLionel Sambuc {
811433d6423SLionel Sambuc return_ACPI_STATUS (AE_NO_MEMORY);
812433d6423SLionel Sambuc }
813433d6423SLionel Sambuc
814433d6423SLionel Sambuc Info->PrefixNode = Node;
815*29492bb7SDavid van Moolenbroek Info->RelativePathname = METHOD_NAME__SRS;
816433d6423SLionel Sambuc Info->Parameters = Args;
817433d6423SLionel Sambuc Info->Flags = ACPI_IGNORE_RETURN_VALUE;
818433d6423SLionel Sambuc
819433d6423SLionel Sambuc /*
820433d6423SLionel Sambuc * The InBuffer parameter will point to a linked list of
821433d6423SLionel Sambuc * resource parameters. It needs to be formatted into a
822433d6423SLionel Sambuc * byte stream to be sent in as an input parameter to _SRS
823433d6423SLionel Sambuc *
824433d6423SLionel Sambuc * Convert the linked list into a byte stream
825433d6423SLionel Sambuc */
826433d6423SLionel Sambuc Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
827*29492bb7SDavid van Moolenbroek Status = AcpiRsCreateAmlResources (InBuffer, &Buffer);
828433d6423SLionel Sambuc if (ACPI_FAILURE (Status))
829433d6423SLionel Sambuc {
830433d6423SLionel Sambuc goto Cleanup;
831433d6423SLionel Sambuc }
832433d6423SLionel Sambuc
833433d6423SLionel Sambuc /* Create and initialize the method parameter object */
834433d6423SLionel Sambuc
835433d6423SLionel Sambuc Args[0] = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);
836433d6423SLionel Sambuc if (!Args[0])
837433d6423SLionel Sambuc {
838433d6423SLionel Sambuc /*
839433d6423SLionel Sambuc * Must free the buffer allocated above (otherwise it is freed
840433d6423SLionel Sambuc * later)
841433d6423SLionel Sambuc */
842433d6423SLionel Sambuc ACPI_FREE (Buffer.Pointer);
843433d6423SLionel Sambuc Status = AE_NO_MEMORY;
844433d6423SLionel Sambuc goto Cleanup;
845433d6423SLionel Sambuc }
846433d6423SLionel Sambuc
847433d6423SLionel Sambuc Args[0]->Buffer.Length = (UINT32) Buffer.Length;
848433d6423SLionel Sambuc Args[0]->Buffer.Pointer = Buffer.Pointer;
849433d6423SLionel Sambuc Args[0]->Common.Flags = AOPOBJ_DATA_VALID;
850433d6423SLionel Sambuc Args[1] = NULL;
851433d6423SLionel Sambuc
852433d6423SLionel Sambuc /* Execute the method, no return value is expected */
853433d6423SLionel Sambuc
854433d6423SLionel Sambuc Status = AcpiNsEvaluate (Info);
855433d6423SLionel Sambuc
856433d6423SLionel Sambuc /* Clean up and return the status from AcpiNsEvaluate */
857433d6423SLionel Sambuc
858433d6423SLionel Sambuc AcpiUtRemoveReference (Args[0]);
859433d6423SLionel Sambuc
860433d6423SLionel Sambuc Cleanup:
861433d6423SLionel Sambuc ACPI_FREE (Info);
862433d6423SLionel Sambuc return_ACPI_STATUS (Status);
863433d6423SLionel Sambuc }
864