rscreate.c revision 1.1.1.2 1 1.1 jruoho /*******************************************************************************
2 1.1 jruoho *
3 1.1 jruoho * Module Name: rscreate - Create resource lists/tables
4 1.1 jruoho *
5 1.1 jruoho ******************************************************************************/
6 1.1 jruoho
7 1.1.1.2 jruoho /*
8 1.1.1.2 jruoho * Copyright (C) 2000 - 2011, Intel Corp.
9 1.1 jruoho * All rights reserved.
10 1.1 jruoho *
11 1.1.1.2 jruoho * Redistribution and use in source and binary forms, with or without
12 1.1.1.2 jruoho * modification, are permitted provided that the following conditions
13 1.1.1.2 jruoho * are met:
14 1.1.1.2 jruoho * 1. Redistributions of source code must retain the above copyright
15 1.1.1.2 jruoho * notice, this list of conditions, and the following disclaimer,
16 1.1.1.2 jruoho * without modification.
17 1.1.1.2 jruoho * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1.1.2 jruoho * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1.1.2 jruoho * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1.1.2 jruoho * including a substantially similar Disclaimer requirement for further
21 1.1.1.2 jruoho * binary redistribution.
22 1.1.1.2 jruoho * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1.1.2 jruoho * of any contributors may be used to endorse or promote products derived
24 1.1.1.2 jruoho * from this software without specific prior written permission.
25 1.1.1.2 jruoho *
26 1.1.1.2 jruoho * Alternatively, this software may be distributed under the terms of the
27 1.1.1.2 jruoho * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1.1.2 jruoho * Software Foundation.
29 1.1.1.2 jruoho *
30 1.1.1.2 jruoho * NO WARRANTY
31 1.1.1.2 jruoho * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1.1.2 jruoho * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.2 jruoho * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1.1.2 jruoho * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1.1.2 jruoho * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1.1.2 jruoho * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1.1.2 jruoho * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1.1.2 jruoho * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1.1.2 jruoho * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1.1.2 jruoho * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1.1.2 jruoho * POSSIBILITY OF SUCH DAMAGES.
42 1.1.1.2 jruoho */
43 1.1 jruoho
44 1.1 jruoho #define __RSCREATE_C__
45 1.1 jruoho
46 1.1 jruoho #include "acpi.h"
47 1.1 jruoho #include "accommon.h"
48 1.1 jruoho #include "acresrc.h"
49 1.1 jruoho #include "acnamesp.h"
50 1.1 jruoho
51 1.1 jruoho #define _COMPONENT ACPI_RESOURCES
52 1.1 jruoho ACPI_MODULE_NAME ("rscreate")
53 1.1 jruoho
54 1.1 jruoho
55 1.1 jruoho /*******************************************************************************
56 1.1 jruoho *
57 1.1 jruoho * FUNCTION: AcpiRsCreateResourceList
58 1.1 jruoho *
59 1.1 jruoho * PARAMETERS: AmlBuffer - Pointer to the resource byte stream
60 1.1 jruoho * OutputBuffer - Pointer to the user's buffer
61 1.1 jruoho *
62 1.1 jruoho * RETURN: Status: AE_OK if okay, else a valid ACPI_STATUS code
63 1.1 jruoho * If OutputBuffer is not large enough, OutputBufferLength
64 1.1 jruoho * indicates how large OutputBuffer should be, else it
65 1.1 jruoho * indicates how may UINT8 elements of OutputBuffer are valid.
66 1.1 jruoho *
67 1.1 jruoho * DESCRIPTION: Takes the byte stream returned from a _CRS, _PRS control method
68 1.1 jruoho * execution and parses the stream to create a linked list
69 1.1 jruoho * of device resources.
70 1.1 jruoho *
71 1.1 jruoho ******************************************************************************/
72 1.1 jruoho
73 1.1 jruoho ACPI_STATUS
74 1.1 jruoho AcpiRsCreateResourceList (
75 1.1 jruoho ACPI_OPERAND_OBJECT *AmlBuffer,
76 1.1 jruoho ACPI_BUFFER *OutputBuffer)
77 1.1 jruoho {
78 1.1 jruoho
79 1.1 jruoho ACPI_STATUS Status;
80 1.1 jruoho UINT8 *AmlStart;
81 1.1 jruoho ACPI_SIZE ListSizeNeeded = 0;
82 1.1 jruoho UINT32 AmlBufferLength;
83 1.1 jruoho void *Resource;
84 1.1 jruoho
85 1.1 jruoho
86 1.1 jruoho ACPI_FUNCTION_TRACE (RsCreateResourceList);
87 1.1 jruoho
88 1.1 jruoho
89 1.1 jruoho ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlBuffer = %p\n",
90 1.1 jruoho AmlBuffer));
91 1.1 jruoho
92 1.1 jruoho /* Params already validated, so we don't re-validate here */
93 1.1 jruoho
94 1.1 jruoho AmlBufferLength = AmlBuffer->Buffer.Length;
95 1.1 jruoho AmlStart = AmlBuffer->Buffer.Pointer;
96 1.1 jruoho
97 1.1 jruoho /*
98 1.1 jruoho * Pass the AmlBuffer into a module that can calculate
99 1.1 jruoho * the buffer size needed for the linked list
100 1.1 jruoho */
101 1.1 jruoho Status = AcpiRsGetListLength (AmlStart, AmlBufferLength,
102 1.1 jruoho &ListSizeNeeded);
103 1.1 jruoho
104 1.1 jruoho ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Status=%X ListSizeNeeded=%X\n",
105 1.1 jruoho Status, (UINT32) ListSizeNeeded));
106 1.1 jruoho if (ACPI_FAILURE (Status))
107 1.1 jruoho {
108 1.1 jruoho return_ACPI_STATUS (Status);
109 1.1 jruoho }
110 1.1 jruoho
111 1.1 jruoho /* Validate/Allocate/Clear caller buffer */
112 1.1 jruoho
113 1.1 jruoho Status = AcpiUtInitializeBuffer (OutputBuffer, ListSizeNeeded);
114 1.1 jruoho if (ACPI_FAILURE (Status))
115 1.1 jruoho {
116 1.1 jruoho return_ACPI_STATUS (Status);
117 1.1 jruoho }
118 1.1 jruoho
119 1.1 jruoho /* Do the conversion */
120 1.1 jruoho
121 1.1 jruoho Resource = OutputBuffer->Pointer;
122 1.1 jruoho Status = AcpiUtWalkAmlResources (AmlStart, AmlBufferLength,
123 1.1 jruoho AcpiRsConvertAmlToResources, &Resource);
124 1.1 jruoho if (ACPI_FAILURE (Status))
125 1.1 jruoho {
126 1.1 jruoho return_ACPI_STATUS (Status);
127 1.1 jruoho }
128 1.1 jruoho
129 1.1 jruoho ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
130 1.1 jruoho OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
131 1.1 jruoho return_ACPI_STATUS (AE_OK);
132 1.1 jruoho }
133 1.1 jruoho
134 1.1 jruoho
135 1.1 jruoho /*******************************************************************************
136 1.1 jruoho *
137 1.1 jruoho * FUNCTION: AcpiRsCreatePciRoutingTable
138 1.1 jruoho *
139 1.1 jruoho * PARAMETERS: PackageObject - Pointer to an ACPI_OPERAND_OBJECT
140 1.1 jruoho * package
141 1.1 jruoho * OutputBuffer - Pointer to the user's buffer
142 1.1 jruoho *
143 1.1 jruoho * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code.
144 1.1 jruoho * If the OutputBuffer is too small, the error will be
145 1.1 jruoho * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point
146 1.1 jruoho * to the size buffer needed.
147 1.1 jruoho *
148 1.1 jruoho * DESCRIPTION: Takes the ACPI_OPERAND_OBJECT package and creates a
149 1.1 jruoho * linked list of PCI interrupt descriptions
150 1.1 jruoho *
151 1.1 jruoho * NOTE: It is the caller's responsibility to ensure that the start of the
152 1.1 jruoho * output buffer is aligned properly (if necessary).
153 1.1 jruoho *
154 1.1 jruoho ******************************************************************************/
155 1.1 jruoho
156 1.1 jruoho ACPI_STATUS
157 1.1 jruoho AcpiRsCreatePciRoutingTable (
158 1.1 jruoho ACPI_OPERAND_OBJECT *PackageObject,
159 1.1 jruoho ACPI_BUFFER *OutputBuffer)
160 1.1 jruoho {
161 1.1 jruoho UINT8 *Buffer;
162 1.1 jruoho ACPI_OPERAND_OBJECT **TopObjectList;
163 1.1 jruoho ACPI_OPERAND_OBJECT **SubObjectList;
164 1.1 jruoho ACPI_OPERAND_OBJECT *ObjDesc;
165 1.1 jruoho ACPI_SIZE BufferSizeNeeded = 0;
166 1.1 jruoho UINT32 NumberOfElements;
167 1.1 jruoho UINT32 Index;
168 1.1 jruoho ACPI_PCI_ROUTING_TABLE *UserPrt;
169 1.1 jruoho ACPI_NAMESPACE_NODE *Node;
170 1.1 jruoho ACPI_STATUS Status;
171 1.1 jruoho ACPI_BUFFER PathBuffer;
172 1.1 jruoho
173 1.1 jruoho
174 1.1 jruoho ACPI_FUNCTION_TRACE (RsCreatePciRoutingTable);
175 1.1 jruoho
176 1.1 jruoho
177 1.1 jruoho /* Params already validated, so we don't re-validate here */
178 1.1 jruoho
179 1.1 jruoho /* Get the required buffer length */
180 1.1 jruoho
181 1.1 jruoho Status = AcpiRsGetPciRoutingTableLength (PackageObject,
182 1.1 jruoho &BufferSizeNeeded);
183 1.1 jruoho if (ACPI_FAILURE (Status))
184 1.1 jruoho {
185 1.1 jruoho return_ACPI_STATUS (Status);
186 1.1 jruoho }
187 1.1 jruoho
188 1.1 jruoho ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "BufferSizeNeeded = %X\n",
189 1.1 jruoho (UINT32) BufferSizeNeeded));
190 1.1 jruoho
191 1.1 jruoho /* Validate/Allocate/Clear caller buffer */
192 1.1 jruoho
193 1.1 jruoho Status = AcpiUtInitializeBuffer (OutputBuffer, BufferSizeNeeded);
194 1.1 jruoho if (ACPI_FAILURE (Status))
195 1.1 jruoho {
196 1.1 jruoho return_ACPI_STATUS (Status);
197 1.1 jruoho }
198 1.1 jruoho
199 1.1 jruoho /*
200 1.1 jruoho * Loop through the ACPI_INTERNAL_OBJECTS - Each object should be a
201 1.1 jruoho * package that in turn contains an UINT64 Address, a UINT8 Pin,
202 1.1 jruoho * a Name, and a UINT8 SourceIndex.
203 1.1 jruoho */
204 1.1 jruoho TopObjectList = PackageObject->Package.Elements;
205 1.1 jruoho NumberOfElements = PackageObject->Package.Count;
206 1.1 jruoho Buffer = OutputBuffer->Pointer;
207 1.1 jruoho UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer);
208 1.1 jruoho
209 1.1 jruoho for (Index = 0; Index < NumberOfElements; Index++)
210 1.1 jruoho {
211 1.1 jruoho /*
212 1.1 jruoho * Point UserPrt past this current structure
213 1.1 jruoho *
214 1.1 jruoho * NOTE: On the first iteration, UserPrt->Length will
215 1.1 jruoho * be zero because we cleared the return buffer earlier
216 1.1 jruoho */
217 1.1 jruoho Buffer += UserPrt->Length;
218 1.1 jruoho UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer);
219 1.1 jruoho
220 1.1 jruoho /*
221 1.1 jruoho * Fill in the Length field with the information we have at this point.
222 1.1 jruoho * The minus four is to subtract the size of the UINT8 Source[4] member
223 1.1 jruoho * because it is added below.
224 1.1 jruoho */
225 1.1 jruoho UserPrt->Length = (sizeof (ACPI_PCI_ROUTING_TABLE) - 4);
226 1.1 jruoho
227 1.1 jruoho /* Each element of the top-level package must also be a package */
228 1.1 jruoho
229 1.1 jruoho if ((*TopObjectList)->Common.Type != ACPI_TYPE_PACKAGE)
230 1.1 jruoho {
231 1.1 jruoho ACPI_ERROR ((AE_INFO,
232 1.1 jruoho "(PRT[%u]) Need sub-package, found %s",
233 1.1 jruoho Index, AcpiUtGetObjectTypeName (*TopObjectList)));
234 1.1 jruoho return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
235 1.1 jruoho }
236 1.1 jruoho
237 1.1 jruoho /* Each sub-package must be of length 4 */
238 1.1 jruoho
239 1.1 jruoho if ((*TopObjectList)->Package.Count != 4)
240 1.1 jruoho {
241 1.1 jruoho ACPI_ERROR ((AE_INFO,
242 1.1 jruoho "(PRT[%u]) Need package of length 4, found length %u",
243 1.1 jruoho Index, (*TopObjectList)->Package.Count));
244 1.1 jruoho return_ACPI_STATUS (AE_AML_PACKAGE_LIMIT);
245 1.1 jruoho }
246 1.1 jruoho
247 1.1 jruoho /*
248 1.1 jruoho * Dereference the sub-package.
249 1.1 jruoho * The SubObjectList will now point to an array of the four IRQ
250 1.1 jruoho * elements: [Address, Pin, Source, SourceIndex]
251 1.1 jruoho */
252 1.1 jruoho SubObjectList = (*TopObjectList)->Package.Elements;
253 1.1 jruoho
254 1.1 jruoho /* 1) First subobject: Dereference the PRT.Address */
255 1.1 jruoho
256 1.1 jruoho ObjDesc = SubObjectList[0];
257 1.1 jruoho if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
258 1.1 jruoho {
259 1.1 jruoho ACPI_ERROR ((AE_INFO, "(PRT[%u].Address) Need Integer, found %s",
260 1.1 jruoho Index, AcpiUtGetObjectTypeName (ObjDesc)));
261 1.1 jruoho return_ACPI_STATUS (AE_BAD_DATA);
262 1.1 jruoho }
263 1.1 jruoho
264 1.1 jruoho UserPrt->Address = ObjDesc->Integer.Value;
265 1.1 jruoho
266 1.1 jruoho /* 2) Second subobject: Dereference the PRT.Pin */
267 1.1 jruoho
268 1.1 jruoho ObjDesc = SubObjectList[1];
269 1.1 jruoho if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
270 1.1 jruoho {
271 1.1 jruoho ACPI_ERROR ((AE_INFO, "(PRT[%u].Pin) Need Integer, found %s",
272 1.1 jruoho Index, AcpiUtGetObjectTypeName (ObjDesc)));
273 1.1 jruoho return_ACPI_STATUS (AE_BAD_DATA);
274 1.1 jruoho }
275 1.1 jruoho
276 1.1 jruoho UserPrt->Pin = (UINT32) ObjDesc->Integer.Value;
277 1.1 jruoho
278 1.1 jruoho /*
279 1.1 jruoho * If the BIOS has erroneously reversed the _PRT SourceName (index 2)
280 1.1 jruoho * and the SourceIndex (index 3), fix it. _PRT is important enough to
281 1.1 jruoho * workaround this BIOS error. This also provides compatibility with
282 1.1 jruoho * other ACPI implementations.
283 1.1 jruoho */
284 1.1 jruoho ObjDesc = SubObjectList[3];
285 1.1 jruoho if (!ObjDesc || (ObjDesc->Common.Type != ACPI_TYPE_INTEGER))
286 1.1 jruoho {
287 1.1 jruoho SubObjectList[3] = SubObjectList[2];
288 1.1 jruoho SubObjectList[2] = ObjDesc;
289 1.1 jruoho
290 1.1 jruoho ACPI_WARNING ((AE_INFO,
291 1.1 jruoho "(PRT[%X].Source) SourceName and SourceIndex are reversed, fixed",
292 1.1 jruoho Index));
293 1.1 jruoho }
294 1.1 jruoho
295 1.1 jruoho /*
296 1.1 jruoho * 3) Third subobject: Dereference the PRT.SourceName
297 1.1 jruoho * The name may be unresolved (slack mode), so allow a null object
298 1.1 jruoho */
299 1.1 jruoho ObjDesc = SubObjectList[2];
300 1.1 jruoho if (ObjDesc)
301 1.1 jruoho {
302 1.1 jruoho switch (ObjDesc->Common.Type)
303 1.1 jruoho {
304 1.1 jruoho case ACPI_TYPE_LOCAL_REFERENCE:
305 1.1 jruoho
306 1.1 jruoho if (ObjDesc->Reference.Class != ACPI_REFCLASS_NAME)
307 1.1 jruoho {
308 1.1 jruoho ACPI_ERROR ((AE_INFO,
309 1.1 jruoho "(PRT[%u].Source) Need name, found Reference Class 0x%X",
310 1.1 jruoho Index, ObjDesc->Reference.Class));
311 1.1 jruoho return_ACPI_STATUS (AE_BAD_DATA);
312 1.1 jruoho }
313 1.1 jruoho
314 1.1 jruoho Node = ObjDesc->Reference.Node;
315 1.1 jruoho
316 1.1 jruoho /* Use *remaining* length of the buffer as max for pathname */
317 1.1 jruoho
318 1.1 jruoho PathBuffer.Length = OutputBuffer->Length -
319 1.1 jruoho (UINT32) ((UINT8 *) UserPrt->Source -
320 1.1 jruoho (UINT8 *) OutputBuffer->Pointer);
321 1.1 jruoho PathBuffer.Pointer = UserPrt->Source;
322 1.1 jruoho
323 1.1 jruoho Status = AcpiNsHandleToPathname ((ACPI_HANDLE) Node, &PathBuffer);
324 1.1 jruoho
325 1.1 jruoho /* +1 to include null terminator */
326 1.1 jruoho
327 1.1 jruoho UserPrt->Length += (UINT32) ACPI_STRLEN (UserPrt->Source) + 1;
328 1.1 jruoho break;
329 1.1 jruoho
330 1.1 jruoho
331 1.1 jruoho case ACPI_TYPE_STRING:
332 1.1 jruoho
333 1.1 jruoho ACPI_STRCPY (UserPrt->Source, ObjDesc->String.Pointer);
334 1.1 jruoho
335 1.1 jruoho /*
336 1.1 jruoho * Add to the Length field the length of the string
337 1.1 jruoho * (add 1 for terminator)
338 1.1 jruoho */
339 1.1 jruoho UserPrt->Length += ObjDesc->String.Length + 1;
340 1.1 jruoho break;
341 1.1 jruoho
342 1.1 jruoho
343 1.1 jruoho case ACPI_TYPE_INTEGER:
344 1.1 jruoho /*
345 1.1 jruoho * If this is a number, then the Source Name is NULL, since the
346 1.1 jruoho * entire buffer was zeroed out, we can leave this alone.
347 1.1 jruoho *
348 1.1 jruoho * Add to the Length field the length of the UINT32 NULL
349 1.1 jruoho */
350 1.1 jruoho UserPrt->Length += sizeof (UINT32);
351 1.1 jruoho break;
352 1.1 jruoho
353 1.1 jruoho
354 1.1 jruoho default:
355 1.1 jruoho
356 1.1 jruoho ACPI_ERROR ((AE_INFO,
357 1.1 jruoho "(PRT[%u].Source) Need Ref/String/Integer, found %s",
358 1.1 jruoho Index, AcpiUtGetObjectTypeName (ObjDesc)));
359 1.1 jruoho return_ACPI_STATUS (AE_BAD_DATA);
360 1.1 jruoho }
361 1.1 jruoho }
362 1.1 jruoho
363 1.1 jruoho /* Now align the current length */
364 1.1 jruoho
365 1.1 jruoho UserPrt->Length = (UINT32) ACPI_ROUND_UP_TO_64BIT (UserPrt->Length);
366 1.1 jruoho
367 1.1 jruoho /* 4) Fourth subobject: Dereference the PRT.SourceIndex */
368 1.1 jruoho
369 1.1 jruoho ObjDesc = SubObjectList[3];
370 1.1 jruoho if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
371 1.1 jruoho {
372 1.1 jruoho ACPI_ERROR ((AE_INFO,
373 1.1 jruoho "(PRT[%u].SourceIndex) Need Integer, found %s",
374 1.1 jruoho Index, AcpiUtGetObjectTypeName (ObjDesc)));
375 1.1 jruoho return_ACPI_STATUS (AE_BAD_DATA);
376 1.1 jruoho }
377 1.1 jruoho
378 1.1 jruoho UserPrt->SourceIndex = (UINT32) ObjDesc->Integer.Value;
379 1.1 jruoho
380 1.1 jruoho /* Point to the next ACPI_OPERAND_OBJECT in the top level package */
381 1.1 jruoho
382 1.1 jruoho TopObjectList++;
383 1.1 jruoho }
384 1.1 jruoho
385 1.1 jruoho ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
386 1.1 jruoho OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
387 1.1 jruoho return_ACPI_STATUS (AE_OK);
388 1.1 jruoho }
389 1.1 jruoho
390 1.1 jruoho
391 1.1 jruoho /*******************************************************************************
392 1.1 jruoho *
393 1.1 jruoho * FUNCTION: AcpiRsCreateAmlResources
394 1.1 jruoho *
395 1.1 jruoho * PARAMETERS: LinkedListBuffer - Pointer to the resource linked list
396 1.1 jruoho * OutputBuffer - Pointer to the user's buffer
397 1.1 jruoho *
398 1.1 jruoho * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code.
399 1.1 jruoho * If the OutputBuffer is too small, the error will be
400 1.1 jruoho * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point
401 1.1 jruoho * to the size buffer needed.
402 1.1 jruoho *
403 1.1 jruoho * DESCRIPTION: Takes the linked list of device resources and
404 1.1 jruoho * creates a bytestream to be used as input for the
405 1.1 jruoho * _SRS control method.
406 1.1 jruoho *
407 1.1 jruoho ******************************************************************************/
408 1.1 jruoho
409 1.1 jruoho ACPI_STATUS
410 1.1 jruoho AcpiRsCreateAmlResources (
411 1.1 jruoho ACPI_RESOURCE *LinkedListBuffer,
412 1.1 jruoho ACPI_BUFFER *OutputBuffer)
413 1.1 jruoho {
414 1.1 jruoho ACPI_STATUS Status;
415 1.1 jruoho ACPI_SIZE AmlSizeNeeded = 0;
416 1.1 jruoho
417 1.1 jruoho
418 1.1 jruoho ACPI_FUNCTION_TRACE (RsCreateAmlResources);
419 1.1 jruoho
420 1.1 jruoho
421 1.1 jruoho ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "LinkedListBuffer = %p\n",
422 1.1 jruoho LinkedListBuffer));
423 1.1 jruoho
424 1.1 jruoho /*
425 1.1 jruoho * Params already validated, so we don't re-validate here
426 1.1 jruoho *
427 1.1 jruoho * Pass the LinkedListBuffer into a module that calculates
428 1.1 jruoho * the buffer size needed for the byte stream.
429 1.1 jruoho */
430 1.1 jruoho Status = AcpiRsGetAmlLength (LinkedListBuffer,
431 1.1 jruoho &AmlSizeNeeded);
432 1.1 jruoho
433 1.1 jruoho ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlSizeNeeded=%X, %s\n",
434 1.1 jruoho (UINT32) AmlSizeNeeded, AcpiFormatException (Status)));
435 1.1 jruoho if (ACPI_FAILURE (Status))
436 1.1 jruoho {
437 1.1 jruoho return_ACPI_STATUS (Status);
438 1.1 jruoho }
439 1.1 jruoho
440 1.1 jruoho /* Validate/Allocate/Clear caller buffer */
441 1.1 jruoho
442 1.1 jruoho Status = AcpiUtInitializeBuffer (OutputBuffer, AmlSizeNeeded);
443 1.1 jruoho if (ACPI_FAILURE (Status))
444 1.1 jruoho {
445 1.1 jruoho return_ACPI_STATUS (Status);
446 1.1 jruoho }
447 1.1 jruoho
448 1.1 jruoho /* Do the conversion */
449 1.1 jruoho
450 1.1 jruoho Status = AcpiRsConvertResourcesToAml (LinkedListBuffer, AmlSizeNeeded,
451 1.1 jruoho OutputBuffer->Pointer);
452 1.1 jruoho if (ACPI_FAILURE (Status))
453 1.1 jruoho {
454 1.1 jruoho return_ACPI_STATUS (Status);
455 1.1 jruoho }
456 1.1 jruoho
457 1.1 jruoho ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
458 1.1 jruoho OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
459 1.1 jruoho return_ACPI_STATUS (AE_OK);
460 1.1 jruoho }
461 1.1 jruoho
462