1 /*******************************************************************************
2 *
3 * Module Name: rscreate - Create resource lists/tables
4 *
5 ******************************************************************************/
6
7 /******************************************************************************
8 *
9 * 1. Copyright Notice
10 *
11 * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp.
12 * All rights reserved.
13 *
14 * 2. License
15 *
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
19 * property rights.
20 *
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
27 *
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
36 *
37 * The above copyright and patent license is granted only if the following
38 * conditions are met:
39 *
40 * 3. Conditions
41 *
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
53 *
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
64 * make.
65 *
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
70 * distribution.
71 *
72 * 3.4. Intel retains all right, title, and interest in and to the Original
73 * Intel Code.
74 *
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
79 *
80 * 4. Disclaimer and Export Compliance
81 *
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88 * PARTICULAR PURPOSE.
89 *
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97 * LIMITED REMEDY.
98 *
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
113 *
114 *****************************************************************************
115 *
116 * Alternatively, you may choose to be licensed under the terms of the
117 * following license:
118 *
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
121 * are met:
122 * 1. Redistributions of source code must retain the above copyright
123 * notice, this list of conditions, and the following disclaimer,
124 * without modification.
125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 * substantially similar to the "NO WARRANTY" disclaimer below
127 * ("Disclaimer") and any redistribution must be conditioned upon
128 * including a substantially similar Disclaimer requirement for further
129 * binary redistribution.
130 * 3. Neither the names of the above-listed copyright holders nor the names
131 * of any contributors may be used to endorse or promote products derived
132 * from this software without specific prior written permission.
133 *
134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145 *
146 * Alternatively, you may choose to be licensed under the terms of the
147 * GNU General Public License ("GPL") version 2 as published by the Free
148 * Software Foundation.
149 *
150 *****************************************************************************/
151
152 #include <contrib/dev/acpica/include/acpi.h>
153 #include <contrib/dev/acpica/include/accommon.h>
154 #include <contrib/dev/acpica/include/acresrc.h>
155 #include <contrib/dev/acpica/include/acnamesp.h>
156
157 #define _COMPONENT ACPI_RESOURCES
158 ACPI_MODULE_NAME ("rscreate")
159
160
161 /*******************************************************************************
162 *
163 * FUNCTION: AcpiBufferToResource
164 *
165 * PARAMETERS: AmlBuffer - Pointer to the resource byte stream
166 * AmlBufferLength - Length of the AmlBuffer
167 * ResourcePtr - Where the converted resource is returned
168 *
169 * RETURN: Status
170 *
171 * DESCRIPTION: Convert a raw AML buffer to a resource list
172 *
173 ******************************************************************************/
174
175 ACPI_STATUS
AcpiBufferToResource(UINT8 * AmlBuffer,UINT16 AmlBufferLength,ACPI_RESOURCE ** ResourcePtr)176 AcpiBufferToResource (
177 UINT8 *AmlBuffer,
178 UINT16 AmlBufferLength,
179 ACPI_RESOURCE **ResourcePtr)
180 {
181 ACPI_STATUS Status;
182 ACPI_SIZE ListSizeNeeded;
183 void *Resource;
184 void *CurrentResourcePtr;
185
186
187 ACPI_FUNCTION_TRACE (AcpiBufferToResource);
188
189
190 /*
191 * Note: we allow AE_AML_NO_RESOURCE_END_TAG, since an end tag
192 * is not required here.
193 */
194
195 /* Get the required length for the converted resource */
196
197 Status = AcpiRsGetListLength (
198 AmlBuffer, AmlBufferLength, &ListSizeNeeded);
199 if (Status == AE_AML_NO_RESOURCE_END_TAG)
200 {
201 Status = AE_OK;
202 }
203 if (ACPI_FAILURE (Status))
204 {
205 return_ACPI_STATUS (Status);
206 }
207
208 /* Allocate a buffer for the converted resource */
209
210 Resource = ACPI_ALLOCATE_ZEROED (ListSizeNeeded);
211 CurrentResourcePtr = Resource;
212 if (!Resource)
213 {
214 return_ACPI_STATUS (AE_NO_MEMORY);
215 }
216
217 /* Perform the AML-to-Resource conversion */
218
219 Status = AcpiUtWalkAmlResources (NULL, AmlBuffer, AmlBufferLength,
220 AcpiRsConvertAmlToResources, &CurrentResourcePtr);
221 if (Status == AE_AML_NO_RESOURCE_END_TAG)
222 {
223 Status = AE_OK;
224 }
225 if (ACPI_FAILURE (Status))
226 {
227 ACPI_FREE (Resource);
228 }
229 else
230 {
231 *ResourcePtr = Resource;
232 }
233
234 return_ACPI_STATUS (Status);
235 }
236
ACPI_EXPORT_SYMBOL(AcpiBufferToResource)237 ACPI_EXPORT_SYMBOL (AcpiBufferToResource)
238
239
240 /*******************************************************************************
241 *
242 * FUNCTION: AcpiRsCreateResourceList
243 *
244 * PARAMETERS: AmlBuffer - Pointer to the resource byte stream
245 * OutputBuffer - Pointer to the user's buffer
246 *
247 * RETURN: Status: AE_OK if okay, else a valid ACPI_STATUS code
248 * If OutputBuffer is not large enough, OutputBufferLength
249 * indicates how large OutputBuffer should be, else it
250 * indicates how may UINT8 elements of OutputBuffer are valid.
251 *
252 * DESCRIPTION: Takes the byte stream returned from a _CRS, _PRS control method
253 * execution and parses the stream to create a linked list
254 * of device resources.
255 *
256 ******************************************************************************/
257
258 ACPI_STATUS
259 AcpiRsCreateResourceList (
260 ACPI_OPERAND_OBJECT *AmlBuffer,
261 ACPI_BUFFER *OutputBuffer)
262 {
263
264 ACPI_STATUS Status;
265 UINT8 *AmlStart;
266 ACPI_SIZE ListSizeNeeded = 0;
267 UINT32 AmlBufferLength;
268 void *Resource;
269
270
271 ACPI_FUNCTION_TRACE (RsCreateResourceList);
272
273
274 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlBuffer = %p\n",
275 AmlBuffer));
276
277 /* Params already validated, so we don't re-validate here */
278
279 AmlBufferLength = AmlBuffer->Buffer.Length;
280 AmlStart = AmlBuffer->Buffer.Pointer;
281
282 /*
283 * Pass the AmlBuffer into a module that can calculate
284 * the buffer size needed for the linked list
285 */
286 Status = AcpiRsGetListLength (AmlStart, AmlBufferLength,
287 &ListSizeNeeded);
288
289 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Status=%X ListSizeNeeded=%X\n",
290 Status, (UINT32) ListSizeNeeded));
291 if (ACPI_FAILURE (Status))
292 {
293 return_ACPI_STATUS (Status);
294 }
295
296 /* Validate/Allocate/Clear caller buffer */
297
298 Status = AcpiUtInitializeBuffer (OutputBuffer, ListSizeNeeded);
299 if (ACPI_FAILURE (Status))
300 {
301 return_ACPI_STATUS (Status);
302 }
303
304 /* Do the conversion */
305
306 Resource = OutputBuffer->Pointer;
307 Status = AcpiUtWalkAmlResources (NULL, AmlStart, AmlBufferLength,
308 AcpiRsConvertAmlToResources, &Resource);
309 if (ACPI_FAILURE (Status))
310 {
311 return_ACPI_STATUS (Status);
312 }
313
314 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
315 OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
316 return_ACPI_STATUS (AE_OK);
317 }
318
319
320 /*******************************************************************************
321 *
322 * FUNCTION: AcpiRsCreatePciRoutingTable
323 *
324 * PARAMETERS: PackageObject - Pointer to a package containing one
325 * of more ACPI_OPERAND_OBJECTs
326 * OutputBuffer - Pointer to the user's buffer
327 *
328 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code.
329 * If the OutputBuffer is too small, the error will be
330 * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point
331 * to the size buffer needed.
332 *
333 * DESCRIPTION: Takes the ACPI_OPERAND_OBJECT package and creates a
334 * linked list of PCI interrupt descriptions
335 *
336 * NOTE: It is the caller's responsibility to ensure that the start of the
337 * output buffer is aligned properly (if necessary).
338 *
339 ******************************************************************************/
340
341 ACPI_STATUS
AcpiRsCreatePciRoutingTable(ACPI_OPERAND_OBJECT * PackageObject,ACPI_BUFFER * OutputBuffer)342 AcpiRsCreatePciRoutingTable (
343 ACPI_OPERAND_OBJECT *PackageObject,
344 ACPI_BUFFER *OutputBuffer)
345 {
346 UINT8 *Buffer;
347 ACPI_OPERAND_OBJECT **TopObjectList;
348 ACPI_OPERAND_OBJECT **SubObjectList;
349 ACPI_OPERAND_OBJECT *ObjDesc;
350 ACPI_SIZE BufferSizeNeeded = 0;
351 UINT32 NumberOfElements;
352 UINT32 Index;
353 ACPI_PCI_ROUTING_TABLE *UserPrt;
354 ACPI_NAMESPACE_NODE *Node;
355 ACPI_STATUS Status;
356 ACPI_BUFFER PathBuffer;
357
358
359 ACPI_FUNCTION_TRACE (RsCreatePciRoutingTable);
360
361
362 /* Params already validated, so we don't re-validate here */
363
364 /* Get the required buffer length */
365
366 Status = AcpiRsGetPciRoutingTableLength (
367 PackageObject,&BufferSizeNeeded);
368 if (ACPI_FAILURE (Status))
369 {
370 return_ACPI_STATUS (Status);
371 }
372
373 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "BufferSizeNeeded = %X\n",
374 (UINT32) BufferSizeNeeded));
375
376 /* Validate/Allocate/Clear caller buffer */
377
378 Status = AcpiUtInitializeBuffer (OutputBuffer, BufferSizeNeeded);
379 if (ACPI_FAILURE (Status))
380 {
381 return_ACPI_STATUS (Status);
382 }
383
384 /*
385 * Loop through the ACPI_INTERNAL_OBJECTS - Each object should be a
386 * package that in turn contains an UINT64 Address, a UINT8 Pin,
387 * a Name, and a UINT8 SourceIndex.
388 */
389 TopObjectList = PackageObject->Package.Elements;
390 NumberOfElements = PackageObject->Package.Count;
391 Buffer = OutputBuffer->Pointer;
392 UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer);
393
394 for (Index = 0; Index < NumberOfElements; Index++)
395 {
396 /*
397 * Point UserPrt past this current structure
398 *
399 * NOTE: On the first iteration, UserPrt->Length will
400 * be zero because we cleared the return buffer earlier
401 */
402 Buffer += UserPrt->Length;
403 UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer);
404
405 /*
406 * Fill in the Length field with the information we have at this
407 * point. The minus four is to subtract the size of the UINT8
408 * Source[4] member because it is added below.
409 */
410 UserPrt->Length = (sizeof (ACPI_PCI_ROUTING_TABLE) - 4);
411
412 /* Each subpackage must be of length 4 */
413
414 if ((*TopObjectList)->Package.Count != 4)
415 {
416 ACPI_ERROR ((AE_INFO,
417 "(PRT[%u]) Need package of length 4, found length %u",
418 Index, (*TopObjectList)->Package.Count));
419 return_ACPI_STATUS (AE_AML_PACKAGE_LIMIT);
420 }
421
422 /*
423 * Dereference the subpackage.
424 * The SubObjectList will now point to an array of the four IRQ
425 * elements: [Address, Pin, Source, SourceIndex]
426 */
427 SubObjectList = (*TopObjectList)->Package.Elements;
428
429 /* 1) First subobject: Dereference the PRT.Address */
430
431 ObjDesc = SubObjectList[0];
432 if (!ObjDesc || ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
433 {
434 ACPI_ERROR ((AE_INFO,
435 "(PRT[%u].Address) Need Integer, found %s",
436 Index, AcpiUtGetObjectTypeName (ObjDesc)));
437 return_ACPI_STATUS (AE_BAD_DATA);
438 }
439
440 UserPrt->Address = ObjDesc->Integer.Value;
441
442 /* 2) Second subobject: Dereference the PRT.Pin */
443
444 ObjDesc = SubObjectList[1];
445 if (!ObjDesc || ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
446 {
447 ACPI_ERROR ((AE_INFO, "(PRT[%u].Pin) Need Integer, found %s",
448 Index, AcpiUtGetObjectTypeName (ObjDesc)));
449 return_ACPI_STATUS (AE_BAD_DATA);
450 }
451
452 UserPrt->Pin = (UINT32) ObjDesc->Integer.Value;
453
454 /*
455 * 3) Third subobject: Dereference the PRT.SourceName
456 * The name may be unresolved (slack mode), so allow a null object
457 */
458 ObjDesc = SubObjectList[2];
459 if (ObjDesc)
460 {
461 switch (ObjDesc->Common.Type)
462 {
463 case ACPI_TYPE_LOCAL_REFERENCE:
464
465 if (ObjDesc->Reference.Class != ACPI_REFCLASS_NAME)
466 {
467 ACPI_ERROR ((AE_INFO,
468 "(PRT[%u].Source) Need name, found Reference Class 0x%X",
469 Index, ObjDesc->Reference.Class));
470 return_ACPI_STATUS (AE_BAD_DATA);
471 }
472
473 Node = ObjDesc->Reference.Node;
474
475 /* Use *remaining* length of the buffer as max for pathname */
476
477 PathBuffer.Length = OutputBuffer->Length -
478 (UINT32) ((UINT8 *) UserPrt->Source -
479 (UINT8 *) OutputBuffer->Pointer);
480 PathBuffer.Pointer = UserPrt->Source;
481
482 Status = AcpiNsHandleToPathname (
483 (ACPI_HANDLE) Node, &PathBuffer, FALSE);
484 if (ACPI_FAILURE (Status))
485 {
486 return_ACPI_STATUS (Status);
487 }
488
489 /* +1 to include null terminator */
490
491 UserPrt->Length += (UINT32) strlen (UserPrt->Source) + 1;
492 break;
493
494 case ACPI_TYPE_STRING:
495
496 strcpy (UserPrt->Source, ObjDesc->String.Pointer);
497
498 /*
499 * Add to the Length field the length of the string
500 * (add 1 for terminator)
501 */
502 UserPrt->Length += ObjDesc->String.Length + 1;
503 break;
504
505 case ACPI_TYPE_INTEGER:
506 /*
507 * If this is a number, then the Source Name is NULL, since
508 * the entire buffer was zeroed out, we can leave this alone.
509 *
510 * Add to the Length field the length of the UINT32 NULL
511 */
512 UserPrt->Length += sizeof (UINT32);
513 break;
514
515 default:
516
517 ACPI_ERROR ((AE_INFO,
518 "(PRT[%u].Source) Need Ref/String/Integer, found %s",
519 Index, AcpiUtGetObjectTypeName (ObjDesc)));
520 return_ACPI_STATUS (AE_BAD_DATA);
521 }
522 }
523
524 /* Now align the current length */
525
526 UserPrt->Length = (UINT32) ACPI_ROUND_UP_TO_64BIT (UserPrt->Length);
527
528 /* 4) Fourth subobject: Dereference the PRT.SourceIndex */
529
530 ObjDesc = SubObjectList[3];
531 if (!ObjDesc || ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
532 {
533 ACPI_ERROR ((AE_INFO,
534 "(PRT[%u].SourceIndex) Need Integer, found %s",
535 Index, AcpiUtGetObjectTypeName (ObjDesc)));
536 return_ACPI_STATUS (AE_BAD_DATA);
537 }
538
539 UserPrt->SourceIndex = (UINT32) ObjDesc->Integer.Value;
540
541 /* Point to the next ACPI_OPERAND_OBJECT in the top level package */
542
543 TopObjectList++;
544 }
545
546 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
547 OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
548 return_ACPI_STATUS (AE_OK);
549 }
550
551
552 /*******************************************************************************
553 *
554 * FUNCTION: AcpiRsCreateAmlResources
555 *
556 * PARAMETERS: ResourceList - Pointer to the resource list buffer
557 * OutputBuffer - Where the AML buffer is returned
558 *
559 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code.
560 * If the OutputBuffer is too small, the error will be
561 * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point
562 * to the size buffer needed.
563 *
564 * DESCRIPTION: Converts a list of device resources to an AML bytestream
565 * to be used as input for the _SRS control method.
566 *
567 ******************************************************************************/
568
569 ACPI_STATUS
AcpiRsCreateAmlResources(ACPI_BUFFER * ResourceList,ACPI_BUFFER * OutputBuffer)570 AcpiRsCreateAmlResources (
571 ACPI_BUFFER *ResourceList,
572 ACPI_BUFFER *OutputBuffer)
573 {
574 ACPI_STATUS Status;
575 ACPI_SIZE AmlSizeNeeded = 0;
576
577
578 ACPI_FUNCTION_TRACE (RsCreateAmlResources);
579
580
581 /* Params already validated, no need to re-validate here */
582
583 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ResourceList Buffer = %p\n",
584 ResourceList->Pointer));
585
586 /* Get the buffer size needed for the AML byte stream */
587
588 Status = AcpiRsGetAmlLength (
589 ResourceList->Pointer, ResourceList->Length, &AmlSizeNeeded);
590
591 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlSizeNeeded=%X, %s\n",
592 (UINT32) AmlSizeNeeded, AcpiFormatException (Status)));
593 if (ACPI_FAILURE (Status))
594 {
595 return_ACPI_STATUS (Status);
596 }
597
598 /* Validate/Allocate/Clear caller buffer */
599
600 Status = AcpiUtInitializeBuffer (OutputBuffer, AmlSizeNeeded);
601 if (ACPI_FAILURE (Status))
602 {
603 return_ACPI_STATUS (Status);
604 }
605
606 /* Do the conversion */
607
608 Status = AcpiRsConvertResourcesToAml (ResourceList->Pointer,
609 AmlSizeNeeded, OutputBuffer->Pointer);
610 if (ACPI_FAILURE (Status))
611 {
612 return_ACPI_STATUS (Status);
613 }
614
615 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
616 OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
617 return_ACPI_STATUS (AE_OK);
618 }
619