nsrepair.c revision 245582
1/******************************************************************************
2 *
3 * Module Name: nsrepair - Repair for objects returned by predefined methods
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2013, 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            NewObject->Common.ReferenceCount =
213                ReturnObject->Common.ReferenceCount;
214
215            if (ReturnObject->Common.ReferenceCount > 1)
216            {
217                ReturnObject->Common.ReferenceCount--;
218            }
219        }
220
221        ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
222            "%s: Converted %s to expected %s at Package index %u\n",
223            Data->Pathname, AcpiUtGetObjectTypeName (ReturnObject),
224            AcpiUtGetObjectTypeName (NewObject), PackageIndex));
225    }
226    else
227    {
228        ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
229            "%s: Converted %s to expected %s\n",
230            Data->Pathname, AcpiUtGetObjectTypeName (ReturnObject),
231            AcpiUtGetObjectTypeName (NewObject)));
232    }
233
234    /* Delete old object, install the new return object */
235
236    AcpiUtRemoveReference (ReturnObject);
237    *ReturnObjectPtr = NewObject;
238    Data->Flags |= ACPI_OBJECT_REPAIRED;
239    return (AE_OK);
240}
241
242
243/*******************************************************************************
244 *
245 * FUNCTION:    AcpiNsConvertToInteger
246 *
247 * PARAMETERS:  OriginalObject      - Object to be converted
248 *              ReturnObject        - Where the new converted object is returned
249 *
250 * RETURN:      Status. AE_OK if conversion was successful.
251 *
252 * DESCRIPTION: Attempt to convert a String/Buffer object to an Integer.
253 *
254 ******************************************************************************/
255
256static ACPI_STATUS
257AcpiNsConvertToInteger (
258    ACPI_OPERAND_OBJECT     *OriginalObject,
259    ACPI_OPERAND_OBJECT     **ReturnObject)
260{
261    ACPI_OPERAND_OBJECT     *NewObject;
262    ACPI_STATUS             Status;
263    UINT64                  Value = 0;
264    UINT32                  i;
265
266
267    switch (OriginalObject->Common.Type)
268    {
269    case ACPI_TYPE_STRING:
270
271        /* String-to-Integer conversion */
272
273        Status = AcpiUtStrtoul64 (OriginalObject->String.Pointer,
274                    ACPI_ANY_BASE, &Value);
275        if (ACPI_FAILURE (Status))
276        {
277            return (Status);
278        }
279        break;
280
281    case ACPI_TYPE_BUFFER:
282
283        /* Buffer-to-Integer conversion. Max buffer size is 64 bits. */
284
285        if (OriginalObject->Buffer.Length > 8)
286        {
287            return (AE_AML_OPERAND_TYPE);
288        }
289
290        /* Extract each buffer byte to create the integer */
291
292        for (i = 0; i < OriginalObject->Buffer.Length; i++)
293        {
294            Value |= ((UINT64) OriginalObject->Buffer.Pointer[i] << (i * 8));
295        }
296        break;
297
298    default:
299        return (AE_AML_OPERAND_TYPE);
300    }
301
302    NewObject = AcpiUtCreateIntegerObject (Value);
303    if (!NewObject)
304    {
305        return (AE_NO_MEMORY);
306    }
307
308    *ReturnObject = NewObject;
309    return (AE_OK);
310}
311
312
313/*******************************************************************************
314 *
315 * FUNCTION:    AcpiNsConvertToString
316 *
317 * PARAMETERS:  OriginalObject      - Object to be converted
318 *              ReturnObject        - Where the new converted object is returned
319 *
320 * RETURN:      Status. AE_OK if conversion was successful.
321 *
322 * DESCRIPTION: Attempt to convert a Integer/Buffer object to a String.
323 *
324 ******************************************************************************/
325
326static ACPI_STATUS
327AcpiNsConvertToString (
328    ACPI_OPERAND_OBJECT     *OriginalObject,
329    ACPI_OPERAND_OBJECT     **ReturnObject)
330{
331    ACPI_OPERAND_OBJECT     *NewObject;
332    ACPI_SIZE               Length;
333    ACPI_STATUS             Status;
334
335
336    switch (OriginalObject->Common.Type)
337    {
338    case ACPI_TYPE_INTEGER:
339        /*
340         * Integer-to-String conversion. Commonly, convert
341         * an integer of value 0 to a NULL string. The last element of
342         * _BIF and _BIX packages occasionally need this fix.
343         */
344        if (OriginalObject->Integer.Value == 0)
345        {
346            /* Allocate a new NULL string object */
347
348            NewObject = AcpiUtCreateStringObject (0);
349            if (!NewObject)
350            {
351                return (AE_NO_MEMORY);
352            }
353        }
354        else
355        {
356            Status = AcpiExConvertToString (OriginalObject, &NewObject,
357                        ACPI_IMPLICIT_CONVERT_HEX);
358            if (ACPI_FAILURE (Status))
359            {
360                return (Status);
361            }
362        }
363        break;
364
365    case ACPI_TYPE_BUFFER:
366        /*
367         * Buffer-to-String conversion. Use a ToString
368         * conversion, no transform performed on the buffer data. The best
369         * example of this is the _BIF method, where the string data from
370         * the battery is often (incorrectly) returned as buffer object(s).
371         */
372        Length = 0;
373        while ((Length < OriginalObject->Buffer.Length) &&
374                (OriginalObject->Buffer.Pointer[Length]))
375        {
376            Length++;
377        }
378
379        /* Allocate a new string object */
380
381        NewObject = AcpiUtCreateStringObject (Length);
382        if (!NewObject)
383        {
384            return (AE_NO_MEMORY);
385        }
386
387        /*
388         * Copy the raw buffer data with no transform. String is already NULL
389         * terminated at Length+1.
390         */
391        ACPI_MEMCPY (NewObject->String.Pointer,
392            OriginalObject->Buffer.Pointer, Length);
393        break;
394
395    default:
396        return (AE_AML_OPERAND_TYPE);
397    }
398
399    *ReturnObject = NewObject;
400    return (AE_OK);
401}
402
403
404/*******************************************************************************
405 *
406 * FUNCTION:    AcpiNsConvertToBuffer
407 *
408 * PARAMETERS:  OriginalObject      - Object to be converted
409 *              ReturnObject        - Where the new converted object is returned
410 *
411 * RETURN:      Status. AE_OK if conversion was successful.
412 *
413 * DESCRIPTION: Attempt to convert a Integer/String/Package object to a Buffer.
414 *
415 ******************************************************************************/
416
417static ACPI_STATUS
418AcpiNsConvertToBuffer (
419    ACPI_OPERAND_OBJECT     *OriginalObject,
420    ACPI_OPERAND_OBJECT     **ReturnObject)
421{
422    ACPI_OPERAND_OBJECT     *NewObject;
423    ACPI_STATUS             Status;
424    ACPI_OPERAND_OBJECT     **Elements;
425    UINT32                  *DwordBuffer;
426    UINT32                  Count;
427    UINT32                  i;
428
429
430    switch (OriginalObject->Common.Type)
431    {
432    case ACPI_TYPE_INTEGER:
433        /*
434         * Integer-to-Buffer conversion.
435         * Convert the Integer to a packed-byte buffer. _MAT and other
436         * objects need this sometimes, if a read has been performed on a
437         * Field object that is less than or equal to the global integer
438         * size (32 or 64 bits).
439         */
440        Status = AcpiExConvertToBuffer (OriginalObject, &NewObject);
441        if (ACPI_FAILURE (Status))
442        {
443            return (Status);
444        }
445        break;
446
447    case ACPI_TYPE_STRING:
448
449        /* String-to-Buffer conversion. Simple data copy */
450
451        NewObject = AcpiUtCreateBufferObject (OriginalObject->String.Length);
452        if (!NewObject)
453        {
454            return (AE_NO_MEMORY);
455        }
456
457        ACPI_MEMCPY (NewObject->Buffer.Pointer,
458            OriginalObject->String.Pointer, OriginalObject->String.Length);
459        break;
460
461    case ACPI_TYPE_PACKAGE:
462        /*
463         * This case is often seen for predefined names that must return a
464         * Buffer object with multiple DWORD integers within. For example,
465         * _FDE and _GTM. The Package can be converted to a Buffer.
466         */
467
468        /* All elements of the Package must be integers */
469
470        Elements = OriginalObject->Package.Elements;
471        Count = OriginalObject->Package.Count;
472
473        for (i = 0; i < Count; i++)
474        {
475            if ((!*Elements) ||
476                ((*Elements)->Common.Type != ACPI_TYPE_INTEGER))
477            {
478                return (AE_AML_OPERAND_TYPE);
479            }
480            Elements++;
481        }
482
483        /* Create the new buffer object to replace the Package */
484
485        NewObject = AcpiUtCreateBufferObject (ACPI_MUL_4 (Count));
486        if (!NewObject)
487        {
488            return (AE_NO_MEMORY);
489        }
490
491        /* Copy the package elements (integers) to the buffer as DWORDs */
492
493        Elements = OriginalObject->Package.Elements;
494        DwordBuffer = ACPI_CAST_PTR (UINT32, NewObject->Buffer.Pointer);
495
496        for (i = 0; i < Count; i++)
497        {
498            *DwordBuffer = (UINT32) (*Elements)->Integer.Value;
499            DwordBuffer++;
500            Elements++;
501        }
502        break;
503
504    default:
505        return (AE_AML_OPERAND_TYPE);
506    }
507
508    *ReturnObject = NewObject;
509    return (AE_OK);
510}
511
512
513/*******************************************************************************
514 *
515 * FUNCTION:    AcpiNsRepairNullElement
516 *
517 * PARAMETERS:  Data                - Pointer to validation data structure
518 *              ExpectedBtypes      - Object types expected
519 *              PackageIndex        - Index of object within parent package (if
520 *                                    applicable - ACPI_NOT_PACKAGE_ELEMENT
521 *                                    otherwise)
522 *              ReturnObjectPtr     - Pointer to the object returned from the
523 *                                    evaluation of a method or object
524 *
525 * RETURN:      Status. AE_OK if repair was successful.
526 *
527 * DESCRIPTION: Attempt to repair a NULL element of a returned Package object.
528 *
529 ******************************************************************************/
530
531ACPI_STATUS
532AcpiNsRepairNullElement (
533    ACPI_PREDEFINED_DATA    *Data,
534    UINT32                  ExpectedBtypes,
535    UINT32                  PackageIndex,
536    ACPI_OPERAND_OBJECT     **ReturnObjectPtr)
537{
538    ACPI_OPERAND_OBJECT     *ReturnObject = *ReturnObjectPtr;
539    ACPI_OPERAND_OBJECT     *NewObject;
540
541
542    ACPI_FUNCTION_NAME (NsRepairNullElement);
543
544
545    /* No repair needed if return object is non-NULL */
546
547    if (ReturnObject)
548    {
549        return (AE_OK);
550    }
551
552    /*
553     * Attempt to repair a NULL element of a Package object. This applies to
554     * predefined names that return a fixed-length package and each element
555     * is required. It does not apply to variable-length packages where NULL
556     * elements are allowed, especially at the end of the package.
557     */
558    if (ExpectedBtypes & ACPI_RTYPE_INTEGER)
559    {
560        /* Need an Integer - create a zero-value integer */
561
562        NewObject = AcpiUtCreateIntegerObject ((UINT64) 0);
563    }
564    else if (ExpectedBtypes & ACPI_RTYPE_STRING)
565    {
566        /* Need a String - create a NULL string */
567
568        NewObject = AcpiUtCreateStringObject (0);
569    }
570    else if (ExpectedBtypes & ACPI_RTYPE_BUFFER)
571    {
572        /* Need a Buffer - create a zero-length buffer */
573
574        NewObject = AcpiUtCreateBufferObject (0);
575    }
576    else
577    {
578        /* Error for all other expected types */
579
580        return (AE_AML_OPERAND_TYPE);
581    }
582
583    if (!NewObject)
584    {
585        return (AE_NO_MEMORY);
586    }
587
588    /* Set the reference count according to the parent Package object */
589
590    NewObject->Common.ReferenceCount = Data->ParentPackage->Common.ReferenceCount;
591
592    ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
593        "%s: Converted NULL package element to expected %s at index %u\n",
594         Data->Pathname, AcpiUtGetObjectTypeName (NewObject), PackageIndex));
595
596    *ReturnObjectPtr = NewObject;
597    Data->Flags |= ACPI_OBJECT_REPAIRED;
598    return (AE_OK);
599}
600
601
602/******************************************************************************
603 *
604 * FUNCTION:    AcpiNsRemoveNullElements
605 *
606 * PARAMETERS:  Data                - Pointer to validation data structure
607 *              PackageType         - An AcpiReturnPackageTypes value
608 *              ObjDesc             - A Package object
609 *
610 * RETURN:      None.
611 *
612 * DESCRIPTION: Remove all NULL package elements from packages that contain
613 *              a variable number of sub-packages. For these types of
614 *              packages, NULL elements can be safely removed.
615 *
616 *****************************************************************************/
617
618void
619AcpiNsRemoveNullElements (
620    ACPI_PREDEFINED_DATA    *Data,
621    UINT8                   PackageType,
622    ACPI_OPERAND_OBJECT     *ObjDesc)
623{
624    ACPI_OPERAND_OBJECT     **Source;
625    ACPI_OPERAND_OBJECT     **Dest;
626    UINT32                  Count;
627    UINT32                  NewCount;
628    UINT32                  i;
629
630
631    ACPI_FUNCTION_NAME (NsRemoveNullElements);
632
633
634    /*
635     * We can safely remove all NULL elements from these package types:
636     * PTYPE1_VAR packages contain a variable number of simple data types.
637     * PTYPE2 packages contain a variable number of sub-packages.
638     */
639    switch (PackageType)
640    {
641    case ACPI_PTYPE1_VAR:
642    case ACPI_PTYPE2:
643    case ACPI_PTYPE2_COUNT:
644    case ACPI_PTYPE2_PKG_COUNT:
645    case ACPI_PTYPE2_FIXED:
646    case ACPI_PTYPE2_MIN:
647    case ACPI_PTYPE2_REV_FIXED:
648    case ACPI_PTYPE2_FIX_VAR:
649        break;
650
651    default:
652    case ACPI_PTYPE1_FIXED:
653    case ACPI_PTYPE1_OPTION:
654        return;
655    }
656
657    Count = ObjDesc->Package.Count;
658    NewCount = Count;
659
660    Source = ObjDesc->Package.Elements;
661    Dest = Source;
662
663    /* Examine all elements of the package object, remove nulls */
664
665    for (i = 0; i < Count; i++)
666    {
667        if (!*Source)
668        {
669            NewCount--;
670        }
671        else
672        {
673            *Dest = *Source;
674            Dest++;
675        }
676        Source++;
677    }
678
679    /* Update parent package if any null elements were removed */
680
681    if (NewCount < Count)
682    {
683        ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
684            "%s: Found and removed %u NULL elements\n",
685            Data->Pathname, (Count - NewCount)));
686
687        /* NULL terminate list and update the package count */
688
689        *Dest = NULL;
690        ObjDesc->Package.Count = NewCount;
691    }
692}
693
694
695/*******************************************************************************
696 *
697 * FUNCTION:    AcpiNsWrapWithPackage
698 *
699 * PARAMETERS:  Data                - Pointer to validation data structure
700 *              OriginalObject      - Pointer to the object to repair.
701 *              ObjDescPtr          - The new package object is returned here
702 *
703 * RETURN:      Status, new object in *ObjDescPtr
704 *
705 * DESCRIPTION: Repair a common problem with objects that are defined to
706 *              return a variable-length Package of sub-objects. If there is
707 *              only one sub-object, some BIOS code mistakenly simply declares
708 *              the single object instead of a Package with one sub-object.
709 *              This function attempts to repair this error by wrapping a
710 *              Package object around the original object, creating the
711 *              correct and expected Package with one sub-object.
712 *
713 *              Names that can be repaired in this manner include:
714 *              _ALR, _CSD, _HPX, _MLS, _PLD, _PRT, _PSS, _TRT, _TSS,
715 *              _BCL, _DOD, _FIX, _Sx
716 *
717 ******************************************************************************/
718
719ACPI_STATUS
720AcpiNsWrapWithPackage (
721    ACPI_PREDEFINED_DATA    *Data,
722    ACPI_OPERAND_OBJECT     *OriginalObject,
723    ACPI_OPERAND_OBJECT     **ObjDescPtr)
724{
725    ACPI_OPERAND_OBJECT     *PkgObjDesc;
726
727
728    ACPI_FUNCTION_NAME (NsWrapWithPackage);
729
730
731    /*
732     * Create the new outer package and populate it. The new package will
733     * have a single element, the lone sub-object.
734     */
735    PkgObjDesc = AcpiUtCreatePackageObject (1);
736    if (!PkgObjDesc)
737    {
738        return (AE_NO_MEMORY);
739    }
740
741    PkgObjDesc->Package.Elements[0] = OriginalObject;
742
743    ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
744        "%s: Wrapped %s with expected Package object\n",
745        Data->Pathname, AcpiUtGetObjectTypeName (OriginalObject)));
746
747    /* Return the new object in the object pointer */
748
749    *ObjDescPtr = PkgObjDesc;
750    Data->Flags |= ACPI_OBJECT_REPAIRED | ACPI_OBJECT_WRAPPED;
751    return (AE_OK);
752}
753