xref: /haiku/src/add-ons/kernel/bus_managers/acpi/acpica/components/namespace/nsrepair.c (revision 5e96d7d537fbec23bad4ae9b4c8e7b02e769f0c6)
1 /******************************************************************************
2  *
3  * Module Name: nsrepair - Repair for objects returned by predefined methods
4  *
5  *****************************************************************************/
6 
7 /******************************************************************************
8  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2013, 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 #define __NSREPAIR_C__
117 
118 #include "acpi.h"
119 #include "accommon.h"
120 #include "acnamesp.h"
121 #include "acinterp.h"
122 #include "acpredef.h"
123 #include "amlresrc.h"
124 
125 #define _COMPONENT          ACPI_NAMESPACE
126         ACPI_MODULE_NAME    ("nsrepair")
127 
128 
129 /*******************************************************************************
130  *
131  * This module attempts to repair or convert objects returned by the
132  * predefined methods to an object type that is expected, as per the ACPI
133  * specification. The need for this code is dictated by the many machines that
134  * return incorrect types for the standard predefined methods. Performing these
135  * conversions here, in one place, eliminates the need for individual ACPI
136  * device drivers to do the same. Note: Most of these conversions are different
137  * than the internal object conversion routines used for implicit object
138  * conversion.
139  *
140  * The following conversions can be performed as necessary:
141  *
142  * Integer -> String
143  * Integer -> Buffer
144  * String  -> Integer
145  * String  -> Buffer
146  * Buffer  -> Integer
147  * Buffer  -> String
148  * Buffer  -> Package of Integers
149  * Package -> Package of one Package
150  *
151  * Additional conversions that are available:
152  *  Convert a null return or zero return value to an EndTag descriptor
153  *  Convert an ASCII string to a Unicode buffer
154  *
155  * An incorrect standalone object is wrapped with required outer package
156  *
157  * Additional possible repairs:
158  * Required package elements that are NULL replaced by Integer/String/Buffer
159  *
160  ******************************************************************************/
161 
162 
163 /* Local prototypes */
164 
165 static const ACPI_SIMPLE_REPAIR_INFO *
166 AcpiNsMatchSimpleRepair (
167     ACPI_NAMESPACE_NODE     *Node,
168     UINT32                  ReturnBtype,
169     UINT32                  PackageIndex);
170 
171 
172 /*
173  * Special but simple repairs for some names.
174  *
175  * 2nd argument: Unexpected types that can be repaired
176  */
177 static const ACPI_SIMPLE_REPAIR_INFO    AcpiObjectRepairInfo[] =
178 {
179     /* Resource descriptor conversions */
180 
181     { "_CRS", ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER | ACPI_RTYPE_NONE,
182                 ACPI_NOT_PACKAGE_ELEMENT,
183                 AcpiNsConvertToResource },
184     { "_DMA", ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER | ACPI_RTYPE_NONE,
185                 ACPI_NOT_PACKAGE_ELEMENT,
186                 AcpiNsConvertToResource },
187     { "_PRS", ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER | ACPI_RTYPE_NONE,
188                 ACPI_NOT_PACKAGE_ELEMENT,
189                 AcpiNsConvertToResource },
190 
191     /* Unicode conversions */
192 
193     { "_MLS", ACPI_RTYPE_STRING, 1,
194                 AcpiNsConvertToUnicode },
195     { "_STR", ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER,
196                 ACPI_NOT_PACKAGE_ELEMENT,
197                 AcpiNsConvertToUnicode },
198     { {0,0,0,0}, 0, 0, NULL } /* Table terminator */
199 };
200 
201 
202 /*******************************************************************************
203  *
204  * FUNCTION:    AcpiNsSimpleRepair
205  *
206  * PARAMETERS:  Info                - Method execution information block
207  *              ExpectedBtypes      - Object types expected
208  *              PackageIndex        - Index of object within parent package (if
209  *                                    applicable - ACPI_NOT_PACKAGE_ELEMENT
210  *                                    otherwise)
211  *              ReturnObjectPtr     - Pointer to the object returned from the
212  *                                    evaluation of a method or object
213  *
214  * RETURN:      Status. AE_OK if repair was successful.
215  *
216  * DESCRIPTION: Attempt to repair/convert a return object of a type that was
217  *              not expected.
218  *
219  ******************************************************************************/
220 
221 ACPI_STATUS
222 AcpiNsSimpleRepair (
223     ACPI_EVALUATE_INFO      *Info,
224     UINT32                  ExpectedBtypes,
225     UINT32                  PackageIndex,
226     ACPI_OPERAND_OBJECT     **ReturnObjectPtr)
227 {
228     ACPI_OPERAND_OBJECT     *ReturnObject = *ReturnObjectPtr;
229     ACPI_OPERAND_OBJECT     *NewObject = NULL;
230     ACPI_STATUS             Status;
231     const ACPI_SIMPLE_REPAIR_INFO   *Predefined;
232 
233 
234     ACPI_FUNCTION_NAME (NsSimpleRepair);
235 
236 
237     /*
238      * Special repairs for certain names that are in the repair table.
239      * Check if this name is in the list of repairable names.
240      */
241     Predefined = AcpiNsMatchSimpleRepair (Info->Node,
242         Info->ReturnBtype, PackageIndex);
243     if (Predefined)
244     {
245         if (!ReturnObject)
246         {
247             ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname,
248                 ACPI_WARN_ALWAYS, "Missing expected return value"));
249         }
250 
251         Status = Predefined->ObjectConverter (ReturnObject, &NewObject);
252         if (ACPI_FAILURE (Status))
253         {
254             /* A fatal error occurred during a conversion */
255 
256             ACPI_EXCEPTION ((AE_INFO, Status,
257                 "During return object analysis"));
258             return (Status);
259         }
260         if (NewObject)
261         {
262             goto ObjectRepaired;
263         }
264     }
265 
266     /*
267      * Do not perform simple object repair unless the return type is not
268      * expected.
269      */
270     if (Info->ReturnBtype & ExpectedBtypes)
271     {
272         return (AE_OK);
273     }
274 
275     /*
276      * At this point, we know that the type of the returned object was not
277      * one of the expected types for this predefined name. Attempt to
278      * repair the object by converting it to one of the expected object
279      * types for this predefined name.
280      */
281 
282     /*
283      * If there is no return value, check if we require a return value for
284      * this predefined name. Either one return value is expected, or none,
285      * for both methods and other objects.
286      *
287      * Exit now if there is no return object. Warning if one was expected.
288      */
289     if (!ReturnObject)
290     {
291         if (ExpectedBtypes && (!(ExpectedBtypes & ACPI_RTYPE_NONE)))
292         {
293             ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname,
294                 ACPI_WARN_ALWAYS, "Missing expected return value"));
295 
296             return (AE_AML_NO_RETURN_VALUE);
297         }
298     }
299 
300     if (ExpectedBtypes & ACPI_RTYPE_INTEGER)
301     {
302         Status = AcpiNsConvertToInteger (ReturnObject, &NewObject);
303         if (ACPI_SUCCESS (Status))
304         {
305             goto ObjectRepaired;
306         }
307     }
308     if (ExpectedBtypes & ACPI_RTYPE_STRING)
309     {
310         Status = AcpiNsConvertToString (ReturnObject, &NewObject);
311         if (ACPI_SUCCESS (Status))
312         {
313             goto ObjectRepaired;
314         }
315     }
316     if (ExpectedBtypes & ACPI_RTYPE_BUFFER)
317     {
318         Status = AcpiNsConvertToBuffer (ReturnObject, &NewObject);
319         if (ACPI_SUCCESS (Status))
320         {
321             goto ObjectRepaired;
322         }
323     }
324     if (ExpectedBtypes & ACPI_RTYPE_PACKAGE)
325     {
326         /*
327          * A package is expected. We will wrap the existing object with a
328          * new package object. It is often the case that if a variable-length
329          * package is required, but there is only a single object needed, the
330          * BIOS will return that object instead of wrapping it with a Package
331          * object. Note: after the wrapping, the package will be validated
332          * for correct contents (expected object type or types).
333          */
334         Status = AcpiNsWrapWithPackage (Info, ReturnObject, &NewObject);
335         if (ACPI_SUCCESS (Status))
336         {
337             /*
338              * The original object just had its reference count
339              * incremented for being inserted into the new package.
340              */
341             *ReturnObjectPtr = NewObject;       /* New Package object */
342             Info->ReturnFlags |= ACPI_OBJECT_REPAIRED;
343             return (AE_OK);
344         }
345     }
346 
347     /* We cannot repair this object */
348 
349     return (AE_AML_OPERAND_TYPE);
350 
351 
352 ObjectRepaired:
353 
354     /* Object was successfully repaired */
355 
356     if (PackageIndex != ACPI_NOT_PACKAGE_ELEMENT)
357     {
358         /*
359          * The original object is a package element. We need to
360          * decrement the reference count of the original object,
361          * for removing it from the package.
362          *
363          * However, if the original object was just wrapped with a
364          * package object as part of the repair, we don't need to
365          * change the reference count.
366          */
367         if (!(Info->ReturnFlags & ACPI_OBJECT_WRAPPED))
368         {
369             NewObject->Common.ReferenceCount =
370                 ReturnObject->Common.ReferenceCount;
371 
372             if (ReturnObject->Common.ReferenceCount > 1)
373             {
374                 ReturnObject->Common.ReferenceCount--;
375             }
376         }
377 
378         ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
379             "%s: Converted %s to expected %s at Package index %u\n",
380             Info->FullPathname, AcpiUtGetObjectTypeName (ReturnObject),
381             AcpiUtGetObjectTypeName (NewObject), PackageIndex));
382     }
383     else
384     {
385         ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
386             "%s: Converted %s to expected %s\n",
387             Info->FullPathname, AcpiUtGetObjectTypeName (ReturnObject),
388             AcpiUtGetObjectTypeName (NewObject)));
389     }
390 
391     /* Delete old object, install the new return object */
392 
393     AcpiUtRemoveReference (ReturnObject);
394     *ReturnObjectPtr = NewObject;
395     Info->ReturnFlags |= ACPI_OBJECT_REPAIRED;
396     return (AE_OK);
397 }
398 
399 
400 /******************************************************************************
401  *
402  * FUNCTION:    AcpiNsMatchSimpleRepair
403  *
404  * PARAMETERS:  Node                - Namespace node for the method/object
405  *              ReturnBtype         - Object type that was returned
406  *              PackageIndex        - Index of object within parent package (if
407  *                                    applicable - ACPI_NOT_PACKAGE_ELEMENT
408  *                                    otherwise)
409  *
410  * RETURN:      Pointer to entry in repair table. NULL indicates not found.
411  *
412  * DESCRIPTION: Check an object name against the repairable object list.
413  *
414  *****************************************************************************/
415 
416 static const ACPI_SIMPLE_REPAIR_INFO *
417 AcpiNsMatchSimpleRepair (
418     ACPI_NAMESPACE_NODE     *Node,
419     UINT32                  ReturnBtype,
420     UINT32                  PackageIndex)
421 {
422     const ACPI_SIMPLE_REPAIR_INFO   *ThisName;
423 
424 
425     /* Search info table for a repairable predefined method/object name */
426 
427     ThisName = AcpiObjectRepairInfo;
428     while (ThisName->ObjectConverter)
429     {
430         if (ACPI_COMPARE_NAME (Node->Name.Ascii, ThisName->Name))
431         {
432             /* Check if we can actually repair this name/type combination */
433 
434             if ((ReturnBtype & ThisName->UnexpectedBtypes) &&
435                 (PackageIndex == ThisName->PackageIndex))
436             {
437                 return (ThisName);
438             }
439 
440             return (NULL);
441         }
442         ThisName++;
443     }
444 
445     return (NULL); /* Name was not found in the repair table */
446 }
447 
448 
449 /*******************************************************************************
450  *
451  * FUNCTION:    AcpiNsRepairNullElement
452  *
453  * PARAMETERS:  Info                - Method execution information block
454  *              ExpectedBtypes      - Object types expected
455  *              PackageIndex        - Index of object within parent package (if
456  *                                    applicable - ACPI_NOT_PACKAGE_ELEMENT
457  *                                    otherwise)
458  *              ReturnObjectPtr     - Pointer to the object returned from the
459  *                                    evaluation of a method or object
460  *
461  * RETURN:      Status. AE_OK if repair was successful.
462  *
463  * DESCRIPTION: Attempt to repair a NULL element of a returned Package object.
464  *
465  ******************************************************************************/
466 
467 ACPI_STATUS
468 AcpiNsRepairNullElement (
469     ACPI_EVALUATE_INFO      *Info,
470     UINT32                  ExpectedBtypes,
471     UINT32                  PackageIndex,
472     ACPI_OPERAND_OBJECT     **ReturnObjectPtr)
473 {
474     ACPI_OPERAND_OBJECT     *ReturnObject = *ReturnObjectPtr;
475     ACPI_OPERAND_OBJECT     *NewObject;
476 
477 
478     ACPI_FUNCTION_NAME (NsRepairNullElement);
479 
480 
481     /* No repair needed if return object is non-NULL */
482 
483     if (ReturnObject)
484     {
485         return (AE_OK);
486     }
487 
488     /*
489      * Attempt to repair a NULL element of a Package object. This applies to
490      * predefined names that return a fixed-length package and each element
491      * is required. It does not apply to variable-length packages where NULL
492      * elements are allowed, especially at the end of the package.
493      */
494     if (ExpectedBtypes & ACPI_RTYPE_INTEGER)
495     {
496         /* Need an Integer - create a zero-value integer */
497 
498         NewObject = AcpiUtCreateIntegerObject ((UINT64) 0);
499     }
500     else if (ExpectedBtypes & ACPI_RTYPE_STRING)
501     {
502         /* Need a String - create a NULL string */
503 
504         NewObject = AcpiUtCreateStringObject (0);
505     }
506     else if (ExpectedBtypes & ACPI_RTYPE_BUFFER)
507     {
508         /* Need a Buffer - create a zero-length buffer */
509 
510         NewObject = AcpiUtCreateBufferObject (0);
511     }
512     else
513     {
514         /* Error for all other expected types */
515 
516         return (AE_AML_OPERAND_TYPE);
517     }
518 
519     if (!NewObject)
520     {
521         return (AE_NO_MEMORY);
522     }
523 
524     /* Set the reference count according to the parent Package object */
525 
526     NewObject->Common.ReferenceCount = Info->ParentPackage->Common.ReferenceCount;
527 
528     ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
529         "%s: Converted NULL package element to expected %s at index %u\n",
530          Info->FullPathname, AcpiUtGetObjectTypeName (NewObject), PackageIndex));
531 
532     *ReturnObjectPtr = NewObject;
533     Info->ReturnFlags |= ACPI_OBJECT_REPAIRED;
534     return (AE_OK);
535 }
536 
537 
538 /******************************************************************************
539  *
540  * FUNCTION:    AcpiNsRemoveNullElements
541  *
542  * PARAMETERS:  Info                - Method execution information block
543  *              PackageType         - An AcpiReturnPackageTypes value
544  *              ObjDesc             - A Package object
545  *
546  * RETURN:      None.
547  *
548  * DESCRIPTION: Remove all NULL package elements from packages that contain
549  *              a variable number of sub-packages. For these types of
550  *              packages, NULL elements can be safely removed.
551  *
552  *****************************************************************************/
553 
554 void
555 AcpiNsRemoveNullElements (
556     ACPI_EVALUATE_INFO      *Info,
557     UINT8                   PackageType,
558     ACPI_OPERAND_OBJECT     *ObjDesc)
559 {
560     ACPI_OPERAND_OBJECT     **Source;
561     ACPI_OPERAND_OBJECT     **Dest;
562     UINT32                  Count;
563     UINT32                  NewCount;
564     UINT32                  i;
565 
566 
567     ACPI_FUNCTION_NAME (NsRemoveNullElements);
568 
569 
570     /*
571      * We can safely remove all NULL elements from these package types:
572      * PTYPE1_VAR packages contain a variable number of simple data types.
573      * PTYPE2 packages contain a variable number of sub-packages.
574      */
575     switch (PackageType)
576     {
577     case ACPI_PTYPE1_VAR:
578     case ACPI_PTYPE2:
579     case ACPI_PTYPE2_COUNT:
580     case ACPI_PTYPE2_PKG_COUNT:
581     case ACPI_PTYPE2_FIXED:
582     case ACPI_PTYPE2_MIN:
583     case ACPI_PTYPE2_REV_FIXED:
584     case ACPI_PTYPE2_FIX_VAR:
585 
586         break;
587 
588     default:
589     case ACPI_PTYPE1_FIXED:
590     case ACPI_PTYPE1_OPTION:
591         return;
592     }
593 
594     Count = ObjDesc->Package.Count;
595     NewCount = Count;
596 
597     Source = ObjDesc->Package.Elements;
598     Dest = Source;
599 
600     /* Examine all elements of the package object, remove nulls */
601 
602     for (i = 0; i < Count; i++)
603     {
604         if (!*Source)
605         {
606             NewCount--;
607         }
608         else
609         {
610             *Dest = *Source;
611             Dest++;
612         }
613         Source++;
614     }
615 
616     /* Update parent package if any null elements were removed */
617 
618     if (NewCount < Count)
619     {
620         ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
621             "%s: Found and removed %u NULL elements\n",
622             Info->FullPathname, (Count - NewCount)));
623 
624         /* NULL terminate list and update the package count */
625 
626         *Dest = NULL;
627         ObjDesc->Package.Count = NewCount;
628     }
629 }
630 
631 
632 /*******************************************************************************
633  *
634  * FUNCTION:    AcpiNsWrapWithPackage
635  *
636  * PARAMETERS:  Info                - Method execution information block
637  *              OriginalObject      - Pointer to the object to repair.
638  *              ObjDescPtr          - The new package object is returned here
639  *
640  * RETURN:      Status, new object in *ObjDescPtr
641  *
642  * DESCRIPTION: Repair a common problem with objects that are defined to
643  *              return a variable-length Package of sub-objects. If there is
644  *              only one sub-object, some BIOS code mistakenly simply declares
645  *              the single object instead of a Package with one sub-object.
646  *              This function attempts to repair this error by wrapping a
647  *              Package object around the original object, creating the
648  *              correct and expected Package with one sub-object.
649  *
650  *              Names that can be repaired in this manner include:
651  *              _ALR, _CSD, _HPX, _MLS, _PLD, _PRT, _PSS, _TRT, _TSS,
652  *              _BCL, _DOD, _FIX, _Sx
653  *
654  ******************************************************************************/
655 
656 ACPI_STATUS
657 AcpiNsWrapWithPackage (
658     ACPI_EVALUATE_INFO      *Info,
659     ACPI_OPERAND_OBJECT     *OriginalObject,
660     ACPI_OPERAND_OBJECT     **ObjDescPtr)
661 {
662     ACPI_OPERAND_OBJECT     *PkgObjDesc;
663 
664 
665     ACPI_FUNCTION_NAME (NsWrapWithPackage);
666 
667 
668     /*
669      * Create the new outer package and populate it. The new package will
670      * have a single element, the lone sub-object.
671      */
672     PkgObjDesc = AcpiUtCreatePackageObject (1);
673     if (!PkgObjDesc)
674     {
675         return (AE_NO_MEMORY);
676     }
677 
678     PkgObjDesc->Package.Elements[0] = OriginalObject;
679 
680     ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
681         "%s: Wrapped %s with expected Package object\n",
682         Info->FullPathname, AcpiUtGetObjectTypeName (OriginalObject)));
683 
684     /* Return the new object in the object pointer */
685 
686     *ObjDescPtr = PkgObjDesc;
687     Info->ReturnFlags |= ACPI_OBJECT_REPAIRED | ACPI_OBJECT_WRAPPED;
688     return (AE_OK);
689 }
690