nsrepair.c revision 233250
1/******************************************************************************
2 *
3 * Module Name: nsrepair - Repair for objects returned by predefined methods
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2012, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 *    notice, this list of conditions, and the following disclaimer,
16 *    without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 *    substantially similar to the "NO WARRANTY" disclaimer below
19 *    ("Disclaimer") and any redistribution must be conditioned upon
20 *    including a substantially similar Disclaimer requirement for further
21 *    binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 *    of any contributors may be used to endorse or promote products derived
24 *    from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#define __NSREPAIR_C__
45
46#include <contrib/dev/acpica/include/acpi.h>
47#include <contrib/dev/acpica/include/accommon.h>
48#include <contrib/dev/acpica/include/acnamesp.h>
49#include <contrib/dev/acpica/include/acinterp.h>
50#include <contrib/dev/acpica/include/acpredef.h>
51
52#define _COMPONENT          ACPI_NAMESPACE
53        ACPI_MODULE_NAME    ("nsrepair")
54
55
56/*******************************************************************************
57 *
58 * This module attempts to repair or convert objects returned by the
59 * predefined methods to an object type that is expected, as per the ACPI
60 * specification. The need for this code is dictated by the many machines that
61 * return incorrect types for the standard predefined methods. Performing these
62 * conversions here, in one place, eliminates the need for individual ACPI
63 * device drivers to do the same. Note: Most of these conversions are different
64 * than the internal object conversion routines used for implicit object
65 * conversion.
66 *
67 * The following conversions can be performed as necessary:
68 *
69 * Integer -> String
70 * Integer -> Buffer
71 * String  -> Integer
72 * String  -> Buffer
73 * Buffer  -> Integer
74 * Buffer  -> String
75 * Buffer  -> Package of Integers
76 * Package -> Package of one Package
77 * An incorrect standalone object is wrapped with required outer package
78 *
79 * Additional possible repairs:
80 * Required package elements that are NULL replaced by Integer/String/Buffer
81 *
82 ******************************************************************************/
83
84
85/* Local prototypes */
86
87static ACPI_STATUS
88AcpiNsConvertToInteger (
89    ACPI_OPERAND_OBJECT     *OriginalObject,
90    ACPI_OPERAND_OBJECT     **ReturnObject);
91
92static ACPI_STATUS
93AcpiNsConvertToString (
94    ACPI_OPERAND_OBJECT     *OriginalObject,
95    ACPI_OPERAND_OBJECT     **ReturnObject);
96
97static ACPI_STATUS
98AcpiNsConvertToBuffer (
99    ACPI_OPERAND_OBJECT     *OriginalObject,
100    ACPI_OPERAND_OBJECT     **ReturnObject);
101
102
103/*******************************************************************************
104 *
105 * FUNCTION:    AcpiNsRepairObject
106 *
107 * PARAMETERS:  Data                - Pointer to validation data structure
108 *              ExpectedBtypes      - Object types expected
109 *              PackageIndex        - Index of object within parent package (if
110 *                                    applicable - ACPI_NOT_PACKAGE_ELEMENT
111 *                                    otherwise)
112 *              ReturnObjectPtr     - Pointer to the object returned from the
113 *                                    evaluation of a method or object
114 *
115 * RETURN:      Status. AE_OK if repair was successful.
116 *
117 * DESCRIPTION: Attempt to repair/convert a return object of a type that was
118 *              not expected.
119 *
120 ******************************************************************************/
121
122ACPI_STATUS
123AcpiNsRepairObject (
124    ACPI_PREDEFINED_DATA    *Data,
125    UINT32                  ExpectedBtypes,
126    UINT32                  PackageIndex,
127    ACPI_OPERAND_OBJECT     **ReturnObjectPtr)
128{
129    ACPI_OPERAND_OBJECT     *ReturnObject = *ReturnObjectPtr;
130    ACPI_OPERAND_OBJECT     *NewObject;
131    ACPI_STATUS             Status;
132
133
134    ACPI_FUNCTION_NAME (NsRepairObject);
135
136
137    /*
138     * At this point, we know that the type of the returned object was not
139     * one of the expected types for this predefined name. Attempt to
140     * repair the object by converting it to one of the expected object
141     * types for this predefined name.
142     */
143    if (ExpectedBtypes & ACPI_RTYPE_INTEGER)
144    {
145        Status = AcpiNsConvertToInteger (ReturnObject, &NewObject);
146        if (ACPI_SUCCESS (Status))
147        {
148            goto ObjectRepaired;
149        }
150    }
151    if (ExpectedBtypes & ACPI_RTYPE_STRING)
152    {
153        Status = AcpiNsConvertToString (ReturnObject, &NewObject);
154        if (ACPI_SUCCESS (Status))
155        {
156            goto ObjectRepaired;
157        }
158    }
159    if (ExpectedBtypes & ACPI_RTYPE_BUFFER)
160    {
161        Status = AcpiNsConvertToBuffer (ReturnObject, &NewObject);
162        if (ACPI_SUCCESS (Status))
163        {
164            goto ObjectRepaired;
165        }
166    }
167    if (ExpectedBtypes & ACPI_RTYPE_PACKAGE)
168    {
169        /*
170         * A package is expected. We will wrap the existing object with a
171         * new package object. It is often the case that if a variable-length
172         * package is required, but there is only a single object needed, the
173         * BIOS will return that object instead of wrapping it with a Package
174         * object. Note: after the wrapping, the package will be validated
175         * for correct contents (expected object type or types).
176         */
177        Status = AcpiNsWrapWithPackage (Data, ReturnObject, &NewObject);
178        if (ACPI_SUCCESS (Status))
179        {
180            /*
181             * The original object just had its reference count
182             * incremented for being inserted into the new package.
183             */
184            *ReturnObjectPtr = NewObject;       /* New Package object */
185            Data->Flags |= ACPI_OBJECT_REPAIRED;
186            return (AE_OK);
187        }
188    }
189
190    /* We cannot repair this object */
191
192    return (AE_AML_OPERAND_TYPE);
193
194
195ObjectRepaired:
196
197    /* Object was successfully repaired */
198
199    if (PackageIndex != ACPI_NOT_PACKAGE_ELEMENT)
200    {
201        /*
202         * The original object is a package element. We need to
203         * decrement the reference count of the original object,
204         * for removing it from the package.
205         *
206         * However, if the original object was just wrapped with a
207         * package object as part of the repair, we don't need to
208         * change the reference count.
209         */
210        if (!(Data->Flags & ACPI_OBJECT_WRAPPED))
211        {
212            if (ReturnObject->Common.ReferenceCount > 1)
213            {
214                ReturnObject->Common.ReferenceCount--;
215            }
216        }
217
218        ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
219            "%s: Converted %s to expected %s at Package index %u\n",
220            Data->Pathname, AcpiUtGetObjectTypeName (ReturnObject),
221            AcpiUtGetObjectTypeName (NewObject), PackageIndex));
222    }
223    else
224    {
225        ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
226            "%s: Converted %s to expected %s\n",
227            Data->Pathname, AcpiUtGetObjectTypeName (ReturnObject),
228            AcpiUtGetObjectTypeName (NewObject)));
229    }
230
231    /* Delete old object, install the new return object */
232
233    AcpiUtRemoveReference (ReturnObject);
234    *ReturnObjectPtr = NewObject;
235    Data->Flags |= ACPI_OBJECT_REPAIRED;
236    return (AE_OK);
237}
238
239
240/*******************************************************************************
241 *
242 * FUNCTION:    AcpiNsConvertToInteger
243 *
244 * PARAMETERS:  OriginalObject      - Object to be converted
245 *              ReturnObject        - Where the new converted object is returned
246 *
247 * RETURN:      Status. AE_OK if conversion was successful.
248 *
249 * DESCRIPTION: Attempt to convert a String/Buffer object to an Integer.
250 *
251 ******************************************************************************/
252
253static ACPI_STATUS
254AcpiNsConvertToInteger (
255    ACPI_OPERAND_OBJECT     *OriginalObject,
256    ACPI_OPERAND_OBJECT     **ReturnObject)
257{
258    ACPI_OPERAND_OBJECT     *NewObject;
259    ACPI_STATUS             Status;
260    UINT64                  Value = 0;
261    UINT32                  i;
262
263
264    switch (OriginalObject->Common.Type)
265    {
266    case ACPI_TYPE_STRING:
267
268        /* String-to-Integer conversion */
269
270        Status = AcpiUtStrtoul64 (OriginalObject->String.Pointer,
271                    ACPI_ANY_BASE, &Value);
272        if (ACPI_FAILURE (Status))
273        {
274            return (Status);
275        }
276        break;
277
278    case ACPI_TYPE_BUFFER:
279
280        /* Buffer-to-Integer conversion. Max buffer size is 64 bits. */
281
282        if (OriginalObject->Buffer.Length > 8)
283        {
284            return (AE_AML_OPERAND_TYPE);
285        }
286
287        /* Extract each buffer byte to create the integer */
288
289        for (i = 0; i < OriginalObject->Buffer.Length; i++)
290        {
291            Value |= ((UINT64) OriginalObject->Buffer.Pointer[i] << (i * 8));
292        }
293        break;
294
295    default:
296        return (AE_AML_OPERAND_TYPE);
297    }
298
299    NewObject = AcpiUtCreateIntegerObject (Value);
300    if (!NewObject)
301    {
302        return (AE_NO_MEMORY);
303    }
304
305    *ReturnObject = NewObject;
306    return (AE_OK);
307}
308
309
310/*******************************************************************************
311 *
312 * FUNCTION:    AcpiNsConvertToString
313 *
314 * PARAMETERS:  OriginalObject      - Object to be converted
315 *              ReturnObject        - Where the new converted object is returned
316 *
317 * RETURN:      Status. AE_OK if conversion was successful.
318 *
319 * DESCRIPTION: Attempt to convert a Integer/Buffer object to a String.
320 *
321 ******************************************************************************/
322
323static ACPI_STATUS
324AcpiNsConvertToString (
325    ACPI_OPERAND_OBJECT     *OriginalObject,
326    ACPI_OPERAND_OBJECT     **ReturnObject)
327{
328    ACPI_OPERAND_OBJECT     *NewObject;
329    ACPI_SIZE               Length;
330    ACPI_STATUS             Status;
331
332
333    switch (OriginalObject->Common.Type)
334    {
335    case ACPI_TYPE_INTEGER:
336        /*
337         * Integer-to-String conversion. Commonly, convert
338         * an integer of value 0 to a NULL string. The last element of
339         * _BIF and _BIX packages occasionally need this fix.
340         */
341        if (OriginalObject->Integer.Value == 0)
342        {
343            /* Allocate a new NULL string object */
344
345            NewObject = AcpiUtCreateStringObject (0);
346            if (!NewObject)
347            {
348                return (AE_NO_MEMORY);
349            }
350        }
351        else
352        {
353            Status = AcpiExConvertToString (OriginalObject, &NewObject,
354                        ACPI_IMPLICIT_CONVERT_HEX);
355            if (ACPI_FAILURE (Status))
356            {
357                return (Status);
358            }
359        }
360        break;
361
362    case ACPI_TYPE_BUFFER:
363        /*
364         * Buffer-to-String conversion. Use a ToString
365         * conversion, no transform performed on the buffer data. The best
366         * example of this is the _BIF method, where the string data from
367         * the battery is often (incorrectly) returned as buffer object(s).
368         */
369        Length = 0;
370        while ((Length < OriginalObject->Buffer.Length) &&
371                (OriginalObject->Buffer.Pointer[Length]))
372        {
373            Length++;
374        }
375
376        /* Allocate a new string object */
377
378        NewObject = AcpiUtCreateStringObject (Length);
379        if (!NewObject)
380        {
381            return (AE_NO_MEMORY);
382        }
383
384        /*
385         * Copy the raw buffer data with no transform. String is already NULL
386         * terminated at Length+1.
387         */
388        ACPI_MEMCPY (NewObject->String.Pointer,
389            OriginalObject->Buffer.Pointer, Length);
390        break;
391
392    default:
393        return (AE_AML_OPERAND_TYPE);
394    }
395
396    *ReturnObject = NewObject;
397    return (AE_OK);
398}
399
400
401/*******************************************************************************
402 *
403 * FUNCTION:    AcpiNsConvertToBuffer
404 *
405 * PARAMETERS:  OriginalObject      - Object to be converted
406 *              ReturnObject        - Where the new converted object is returned
407 *
408 * RETURN:      Status. AE_OK if conversion was successful.
409 *
410 * DESCRIPTION: Attempt to convert a Integer/String/Package object to a Buffer.
411 *
412 ******************************************************************************/
413
414static ACPI_STATUS
415AcpiNsConvertToBuffer (
416    ACPI_OPERAND_OBJECT     *OriginalObject,
417    ACPI_OPERAND_OBJECT     **ReturnObject)
418{
419    ACPI_OPERAND_OBJECT     *NewObject;
420    ACPI_STATUS             Status;
421    ACPI_OPERAND_OBJECT     **Elements;
422    UINT32                  *DwordBuffer;
423    UINT32                  Count;
424    UINT32                  i;
425
426
427    switch (OriginalObject->Common.Type)
428    {
429    case ACPI_TYPE_INTEGER:
430        /*
431         * Integer-to-Buffer conversion.
432         * Convert the Integer to a packed-byte buffer. _MAT and other
433         * objects need this sometimes, if a read has been performed on a
434         * Field object that is less than or equal to the global integer
435         * size (32 or 64 bits).
436         */
437        Status = AcpiExConvertToBuffer (OriginalObject, &NewObject);
438        if (ACPI_FAILURE (Status))
439        {
440            return (Status);
441        }
442        break;
443
444    case ACPI_TYPE_STRING:
445
446        /* String-to-Buffer conversion. Simple data copy */
447
448        NewObject = AcpiUtCreateBufferObject (OriginalObject->String.Length);
449        if (!NewObject)
450        {
451            return (AE_NO_MEMORY);
452        }
453
454        ACPI_MEMCPY (NewObject->Buffer.Pointer,
455            OriginalObject->String.Pointer, OriginalObject->String.Length);
456        break;
457
458    case ACPI_TYPE_PACKAGE:
459        /*
460         * This case is often seen for predefined names that must return a
461         * Buffer object with multiple DWORD integers within. For example,
462         * _FDE and _GTM. The Package can be converted to a Buffer.
463         */
464
465        /* All elements of the Package must be integers */
466
467        Elements = OriginalObject->Package.Elements;
468        Count = OriginalObject->Package.Count;
469
470        for (i = 0; i < Count; i++)
471        {
472            if ((!*Elements) ||
473                ((*Elements)->Common.Type != ACPI_TYPE_INTEGER))
474            {
475                return (AE_AML_OPERAND_TYPE);
476            }
477            Elements++;
478        }
479
480        /* Create the new buffer object to replace the Package */
481
482        NewObject = AcpiUtCreateBufferObject (ACPI_MUL_4 (Count));
483        if (!NewObject)
484        {
485            return (AE_NO_MEMORY);
486        }
487
488        /* Copy the package elements (integers) to the buffer as DWORDs */
489
490        Elements = OriginalObject->Package.Elements;
491        DwordBuffer = ACPI_CAST_PTR (UINT32, NewObject->Buffer.Pointer);
492
493        for (i = 0; i < Count; i++)
494        {
495            *DwordBuffer = (UINT32) (*Elements)->Integer.Value;
496            DwordBuffer++;
497            Elements++;
498        }
499        break;
500
501    default:
502        return (AE_AML_OPERAND_TYPE);
503    }
504
505    *ReturnObject = NewObject;
506    return (AE_OK);
507}
508
509
510/*******************************************************************************
511 *
512 * FUNCTION:    AcpiNsRepairNullElement
513 *
514 * PARAMETERS:  Data                - Pointer to validation data structure
515 *              ExpectedBtypes      - Object types expected
516 *              PackageIndex        - Index of object within parent package (if
517 *                                    applicable - ACPI_NOT_PACKAGE_ELEMENT
518 *                                    otherwise)
519 *              ReturnObjectPtr     - Pointer to the object returned from the
520 *                                    evaluation of a method or object
521 *
522 * RETURN:      Status. AE_OK if repair was successful.
523 *
524 * DESCRIPTION: Attempt to repair a NULL element of a returned Package object.
525 *
526 ******************************************************************************/
527
528ACPI_STATUS
529AcpiNsRepairNullElement (
530    ACPI_PREDEFINED_DATA    *Data,
531    UINT32                  ExpectedBtypes,
532    UINT32                  PackageIndex,
533    ACPI_OPERAND_OBJECT     **ReturnObjectPtr)
534{
535    ACPI_OPERAND_OBJECT     *ReturnObject = *ReturnObjectPtr;
536    ACPI_OPERAND_OBJECT     *NewObject;
537
538
539    ACPI_FUNCTION_NAME (NsRepairNullElement);
540
541
542    /* No repair needed if return object is non-NULL */
543
544    if (ReturnObject)
545    {
546        return (AE_OK);
547    }
548
549    /*
550     * Attempt to repair a NULL element of a Package object. This applies to
551     * predefined names that return a fixed-length package and each element
552     * is required. It does not apply to variable-length packages where NULL
553     * elements are allowed, especially at the end of the package.
554     */
555    if (ExpectedBtypes & ACPI_RTYPE_INTEGER)
556    {
557        /* Need an Integer - create a zero-value integer */
558
559        NewObject = AcpiUtCreateIntegerObject ((UINT64) 0);
560    }
561    else if (ExpectedBtypes & ACPI_RTYPE_STRING)
562    {
563        /* Need a String - create a NULL string */
564
565        NewObject = AcpiUtCreateStringObject (0);
566    }
567    else if (ExpectedBtypes & ACPI_RTYPE_BUFFER)
568    {
569        /* Need a Buffer - create a zero-length buffer */
570
571        NewObject = AcpiUtCreateBufferObject (0);
572    }
573    else
574    {
575        /* Error for all other expected types */
576
577        return (AE_AML_OPERAND_TYPE);
578    }
579
580    if (!NewObject)
581    {
582        return (AE_NO_MEMORY);
583    }
584
585    /* Set the reference count according to the parent Package object */
586
587    NewObject->Common.ReferenceCount = Data->ParentPackage->Common.ReferenceCount;
588
589    ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
590        "%s: Converted NULL package element to expected %s at index %u\n",
591         Data->Pathname, AcpiUtGetObjectTypeName (NewObject), PackageIndex));
592
593    *ReturnObjectPtr = NewObject;
594    Data->Flags |= ACPI_OBJECT_REPAIRED;
595    return (AE_OK);
596}
597
598
599/******************************************************************************
600 *
601 * FUNCTION:    AcpiNsRemoveNullElements
602 *
603 * PARAMETERS:  Data                - Pointer to validation data structure
604 *              PackageType         - An AcpiReturnPackageTypes value
605 *              ObjDesc             - A Package object
606 *
607 * RETURN:      None.
608 *
609 * DESCRIPTION: Remove all NULL package elements from packages that contain
610 *              a variable number of sub-packages. For these types of
611 *              packages, NULL elements can be safely removed.
612 *
613 *****************************************************************************/
614
615void
616AcpiNsRemoveNullElements (
617    ACPI_PREDEFINED_DATA    *Data,
618    UINT8                   PackageType,
619    ACPI_OPERAND_OBJECT     *ObjDesc)
620{
621    ACPI_OPERAND_OBJECT     **Source;
622    ACPI_OPERAND_OBJECT     **Dest;
623    UINT32                  Count;
624    UINT32                  NewCount;
625    UINT32                  i;
626
627
628    ACPI_FUNCTION_NAME (NsRemoveNullElements);
629
630
631    /*
632     * We can safely remove all NULL elements from these package types:
633     * PTYPE1_VAR packages contain a variable number of simple data types.
634     * PTYPE2 packages contain a variable number of sub-packages.
635     */
636    switch (PackageType)
637    {
638    case ACPI_PTYPE1_VAR:
639    case ACPI_PTYPE2:
640    case ACPI_PTYPE2_COUNT:
641    case ACPI_PTYPE2_PKG_COUNT:
642    case ACPI_PTYPE2_FIXED:
643    case ACPI_PTYPE2_MIN:
644    case ACPI_PTYPE2_REV_FIXED:
645    case ACPI_PTYPE2_FIX_VAR:
646        break;
647
648    default:
649    case ACPI_PTYPE1_FIXED:
650    case ACPI_PTYPE1_OPTION:
651        return;
652    }
653
654    Count = ObjDesc->Package.Count;
655    NewCount = Count;
656
657    Source = ObjDesc->Package.Elements;
658    Dest = Source;
659
660    /* Examine all elements of the package object, remove nulls */
661
662    for (i = 0; i < Count; i++)
663    {
664        if (!*Source)
665        {
666            NewCount--;
667        }
668        else
669        {
670            *Dest = *Source;
671            Dest++;
672        }
673        Source++;
674    }
675
676    /* Update parent package if any null elements were removed */
677
678    if (NewCount < Count)
679    {
680        ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
681            "%s: Found and removed %u NULL elements\n",
682            Data->Pathname, (Count - NewCount)));
683
684        /* NULL terminate list and update the package count */
685
686        *Dest = NULL;
687        ObjDesc->Package.Count = NewCount;
688    }
689}
690
691
692/*******************************************************************************
693 *
694 * FUNCTION:    AcpiNsWrapWithPackage
695 *
696 * PARAMETERS:  Data                - Pointer to validation data structure
697 *              OriginalObject      - Pointer to the object to repair.
698 *              ObjDescPtr          - The new package object is returned here
699 *
700 * RETURN:      Status, new object in *ObjDescPtr
701 *
702 * DESCRIPTION: Repair a common problem with objects that are defined to
703 *              return a variable-length Package of sub-objects. If there is
704 *              only one sub-object, some BIOS code mistakenly simply declares
705 *              the single object instead of a Package with one sub-object.
706 *              This function attempts to repair this error by wrapping a
707 *              Package object around the original object, creating the
708 *              correct and expected Package with one sub-object.
709 *
710 *              Names that can be repaired in this manner include:
711 *              _ALR, _CSD, _HPX, _MLS, _PLD, _PRT, _PSS, _TRT, _TSS,
712 *              _BCL, _DOD, _FIX, _Sx
713 *
714 ******************************************************************************/
715
716ACPI_STATUS
717AcpiNsWrapWithPackage (
718    ACPI_PREDEFINED_DATA    *Data,
719    ACPI_OPERAND_OBJECT     *OriginalObject,
720    ACPI_OPERAND_OBJECT     **ObjDescPtr)
721{
722    ACPI_OPERAND_OBJECT     *PkgObjDesc;
723
724
725    ACPI_FUNCTION_NAME (NsWrapWithPackage);
726
727
728    /*
729     * Create the new outer package and populate it. The new package will
730     * have a single element, the lone sub-object.
731     */
732    PkgObjDesc = AcpiUtCreatePackageObject (1);
733    if (!PkgObjDesc)
734    {
735        return (AE_NO_MEMORY);
736    }
737
738    PkgObjDesc->Package.Elements[0] = OriginalObject;
739
740    ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
741        "%s: Wrapped %s with expected Package object\n",
742        Data->Pathname, AcpiUtGetObjectTypeName (OriginalObject)));
743
744    /* Return the new object in the object pointer */
745
746    *ObjDescPtr = PkgObjDesc;
747    Data->Flags |= ACPI_OBJECT_REPAIRED | ACPI_OBJECT_WRAPPED;
748    return (AE_OK);
749}
750